Merge pull request #851 from databus23/patch-1
ensure private key and certificate match
This commit is contained in:
commit
f5a6b79dbd
1 changed files with 7 additions and 0 deletions
|
@ -20,6 +20,7 @@ import (
|
|||
"crypto/rand"
|
||||
"crypto/rsa"
|
||||
"crypto/sha1"
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"crypto/x509/pkix"
|
||||
"encoding/hex"
|
||||
|
@ -90,6 +91,12 @@ func AddOrUpdateCertAndKey(name string, cert, key, ca []byte) (*ingress.SSLCert,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
//Ensure that certificate and private key have a matching public key
|
||||
if _, err := tls.X509KeyPair(cert, key); err != nil {
|
||||
_ = os.Remove(tempPemFile.Name())
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cn := []string{pemCert.Subject.CommonName}
|
||||
if len(pemCert.DNSNames) > 0 {
|
||||
cn = append(cn, pemCert.DNSNames...)
|
||||
|
|
Loading…
Reference in a new issue