项目作者: nathanejohnson

项目描述 :
Go http transport and http client that will communicate with https websites that do not present their intermediate certificates, provided it can complete the chain. Also validates stapled OCSP responses, and supports OCSP must staple
高级语言: Go
项目地址: git://github.com/nathanejohnson/intransport.git
创建时间: 2018-03-02T01:31:26Z
项目社区:https://github.com/nathanejohnson/intransport

开源协议:MIT License

下载


GoDoc
Go Report Card
Build Status

Package intransport implements the http RoundTripper interface. This can be used with, for example, http.Client and httputil.ReverseProxy. This package is meant to allow secure communications with remote hosts that may not fully specify their intermediate certificates on the TLS handshake. Most browsers support communication with these hosts by using the issuing certificate URL from the Authority Information Access extension of the cert to fetch any missing intermediates. Each intermediate is fetched in turn until it can either complete the chain back to a trusted root or give up after all avenues have been exhausted, in which case it displays an error. Go’s default transport does not fetch intermediates and will fail on mis-configured hosts. This package attempts to emulate browser behavior by attempting to complete the chain to a trusted root by fetching any missing intermediates.

Additionally, this will validate any stapled OCSP responses, and in the case where the certificate was created with the Must Staple extension set, it will fail in the absence of a validated OCSP response.

In order to use this, for most use cases, will be simply:

  1. package main
  2. import (
  3. "fmt"
  4. "io/ioutil"
  5. "os"
  6. it "github.com/nathanejohnson/intransport/v2"
  7. )
  8. func main() {
  9. c := it.NewInTransportHTTPClient(nil)
  10. resp, err := c.Get("https://something.org")
  11. if err != nil {
  12. fmt.Println("boo, hiss! ", err)
  13. os.Exit(1)
  14. }
  15. body, err := ioutil.ReadAll(resp.Body)
  16. _ = resp.Body.Close()
  17. if err != nil {
  18. fmt.Println("ba dum, tiss! ", err)
  19. os.Exit(1)
  20. }
  21. fmt.Printf("got response:\n%s", string(body))
  22. }

Note: v2 package supports only go 1.15 and newer due to the use of tls VerifyConn.