Skip to content

Commit 505cea0

Browse files
authored
Fix issue when client is used with APIKey (#36)
1 parent 83fb2bb commit 505cea0

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

kms/client.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,22 @@ func NewClient(conf *Config) (*Client, error) {
6464
return nil, errors.New("kms: invalid config: 'APIKey' and 'TLS.GetClientCertificate' are present")
6565
}
6666

67-
tlsConf := conf.TLS.Clone()
67+
tlsConf := conf.TLS
6868
if conf.APIKey != nil {
6969
cert, err := GenerateCertificate(conf.APIKey, nil)
7070
if err != nil {
7171
return nil, err
7272
}
73+
74+
// ensure that the TLS configuration is not nil and
75+
// the TLS configuration is cloned to avoid
76+
// modifying the original TLS configuration.
77+
if tlsConf == nil {
78+
tlsConf = &tls.Config{}
79+
} else {
80+
tlsConf = tlsConf.Clone()
81+
}
82+
7383
tlsConf.GetClientCertificate = func(*tls.CertificateRequestInfo) (*tls.Certificate, error) {
7484
return &cert, nil
7585
}

0 commit comments

Comments
 (0)