Improve code reusability
Signed-off-by: renxiangyu_yewu <renxiangyu_yewu@cmss.chinamobile.com>
This commit is contained in:
parent
992802084f
commit
11f8fe3161
|
@ -347,10 +347,6 @@ func NewSignedCert(cc *CertConfig, key crypto.Signer, caCert *x509.Certificate,
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoveDuplicateAltNames(&cc.Config.AltNames)
|
RemoveDuplicateAltNames(&cc.Config.AltNames)
|
||||||
notAfter := time.Now().Add(constants.CertificateValidity).UTC()
|
|
||||||
if cc.NotAfter != nil {
|
|
||||||
notAfter = *cc.NotAfter
|
|
||||||
}
|
|
||||||
|
|
||||||
certTmpl := x509.Certificate{
|
certTmpl := x509.Certificate{
|
||||||
Subject: pkix.Name{
|
Subject: pkix.Name{
|
||||||
|
@ -361,7 +357,7 @@ func NewSignedCert(cc *CertConfig, key crypto.Signer, caCert *x509.Certificate,
|
||||||
IPAddresses: cc.Config.AltNames.IPs,
|
IPAddresses: cc.Config.AltNames.IPs,
|
||||||
SerialNumber: serial,
|
SerialNumber: serial,
|
||||||
NotBefore: caCert.NotBefore,
|
NotBefore: caCert.NotBefore,
|
||||||
NotAfter: notAfter,
|
NotAfter: cc.NotAfter.UTC(),
|
||||||
KeyUsage: keyUsage,
|
KeyUsage: keyUsage,
|
||||||
ExtKeyUsage: cc.Config.Usages,
|
ExtKeyUsage: cc.Config.Usages,
|
||||||
BasicConstraintsValid: true,
|
BasicConstraintsValid: true,
|
||||||
|
|
Loading…
Reference in New Issue