Documentation ¶
Index ¶
- func DebugRequest(req *http.Request) string
- func DebugResponse(r *http.Response) string
- func DrainBody(b io.ReadCloser) (r1, r2 io.ReadCloser, err error)
- func NewBuilder() *mTLSClientBuilder
- func NewMATLSClient(config MATLSConfig) (*http.Client, error)
- func RootCAPoolFromCerts(certs []*x509.Certificate) *x509.CertPool
- func RootCASCertificate(pemBytes []byte) (*x509.Certificate, error)
- func RootCASFromFile(path string) (*x509.Certificate, error)
- func RootCAs(cas []string) ([]*x509.Certificate, error)
- func TlsCertFromFile(keyPath, certPath string) ([]tls.Certificate, error)
- func TlsClientCert(certPEMBlock, keyPEMBlock []byte) ([]tls.Certificate, error)
- type MATLSClientBuilder
- type MATLSConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DebugRequest ¶
func DebugResponse ¶
func DrainBody ¶
func DrainBody(b io.ReadCloser) (r1, r2 io.ReadCloser, err error)
https://golang.ir/src/net/http/httputil/dump.go drainBody reads all of b to memory and then returns two equivalent ReadClosers yielding the same bytes.
It returns an error if the initial slurp of all bytes fails. It does not attempt to make the returned ReadClosers have identical error-matching behavior.
func NewBuilder ¶
func NewBuilder() *mTLSClientBuilder
func NewMATLSClient ¶
func NewMATLSClient(config MATLSConfig) (*http.Client, error)
NewMATLSClient creates a new http client that is configured for Mutually Authenticated TLS. `insecureSkipVerify` can be set to true if host certificates are not to be validated against a local trusted list of CA certificates. `caCerts` is an optional list of root CA certificates that can be used to validate host certificates. Can be set to nil if not required.
func RootCAPoolFromCerts ¶
func RootCAPoolFromCerts(certs []*x509.Certificate) *x509.CertPool
func RootCASCertificate ¶
func RootCASCertificate(pemBytes []byte) (*x509.Certificate, error)
func RootCASFromFile ¶
func RootCASFromFile(path string) (*x509.Certificate, error)
func TlsCertFromFile ¶
func TlsCertFromFile(keyPath, certPath string) ([]tls.Certificate, error)
func TlsClientCert ¶
func TlsClientCert(certPEMBlock, keyPEMBlock []byte) ([]tls.Certificate, error)
Types ¶
type MATLSClientBuilder ¶
type MATLSClientBuilder interface { WithRootCAs(rootCAs []string) MATLSClientBuilder WithTransportKeyPair(certPEMBlock, keyPEMBlock string) MATLSClientBuilder Build() (*http.Client, error) }
type MATLSConfig ¶
type MATLSConfig struct { ClientCerts []tls.Certificate InsecureSkipVerify bool RootCAs []*x509.Certificate TLSMinVersion uint16 }