File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -75,6 +75,17 @@ type TLSClientOptions struct {
7575 // by the server are validated. If false, any certificate is accepted.
7676 InsecureSkipVerify bool
7777
78+ // VerifyPeerCertificate, if not nil, is called after normal
79+ // certificate verification. It receives the raw ASN.1 certificates
80+ // provided by the peer and also any verified chains that normal processing found.
81+ // If it returns a non-nil error, the handshake is aborted and that error results.
82+ //
83+ // If normal verification fails then the handshake will abort before
84+ // considering this callback. If normal verification is disabled by
85+ // setting InsecureSkipVerify then this callback will be considered but
86+ // the verifiedChains argument will always be nil.
87+ VerifyPeerCertificate func (rawCerts [][]byte , verifiedChains [][]* x509.Certificate ) error
88+
7889 // Prevents callers using unkeyed fields.
7990 _ struct {}
8091}
@@ -121,6 +132,8 @@ func TLSClientAuth(opts TLSClientOptions) (*tls.Config, error) {
121132
122133 cfg .InsecureSkipVerify = opts .InsecureSkipVerify
123134
135+ cfg .VerifyPeerCertificate = opts .VerifyPeerCertificate
136+
124137 // When no CA certificate is provided, default to the system cert pool
125138 // that way when a request is made to a server known by the system trust store,
126139 // the name is still verified
You can’t perform that action at this time.
0 commit comments