@@ -17,6 +17,8 @@ package service
17
17
import (
18
18
"bytes"
19
19
"context"
20
+ "crypto"
21
+ "crypto/rsa"
20
22
"crypto/sha256"
21
23
"crypto/tls"
22
24
"crypto/x509"
@@ -109,6 +111,7 @@ func NewTLSConfigWithTLSCertificateCache(cfg config.TLS) (*tls.Config, *TLSCerti
109
111
if err != nil {
110
112
return nil , nil , errors .Wrap (err , "tls.LoadX509KeyPair(cert, key)" )
111
113
}
114
+ warnIfRSAPrivateKey (crt .PrivateKey )
112
115
113
116
crtHash , err := hash (cert )
114
117
if err != nil {
@@ -131,6 +134,8 @@ func NewTLSConfigWithTLSCertificateCache(cfg config.TLS) (*tls.Config, *TLSCerti
131
134
if err != nil {
132
135
return nil , nil , errors .Wrap (err , "tls.LoadX509KeyPair(cert, key)" )
133
136
}
137
+ warnIfRSAPrivateKey (crt .PrivateKey )
138
+
134
139
t .Certificates = make ([]tls.Certificate , 1 )
135
140
t .Certificates [0 ] = crt
136
141
}
@@ -204,6 +209,8 @@ func (tcc *TLSCertificateCache) RefreshCertificate(ctx context.Context) error {
204
209
tcc .serverCertMutex .Unlock ()
205
210
continue
206
211
}
212
+ warnIfRSAPrivateKey (newCert .PrivateKey )
213
+
207
214
tcc .serverCert .Store (& newCert )
208
215
tcc .serverCertHash = serverCertHash
209
216
tcc .serverCertKeyHash = serverCertKeyHash
@@ -293,3 +300,10 @@ func defaultCipherSuitesMap() map[string]uint16 {
293
300
}
294
301
return ciphers
295
302
}
303
+
304
+ // warnIfRSAPrivateKey output warning log if the private key is RSA.
305
+ func warnIfRSAPrivateKey (privateKey crypto.PrivateKey ) {
306
+ if _ , ok := privateKey .(* rsa.PrivateKey ); ok {
307
+ glg .Warn ("The private key used in the server certificate is RSA. Consider using an ECDSA key for better performance." )
308
+ }
309
+ }
0 commit comments