Skip to content

Commit dc767fe

Browse files
Equanoxcasualjim
authored andcommitted
Add tls option VerifyPeerCertificate
Signed-off-by: equanox <matthias@benchkram.de>
1 parent 1c4afa5 commit dc767fe

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

client/runtime.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)