Skip to content

Commit ce1eb0a

Browse files
committed
Use new x509util for renew/rekey.
1 parent f437b86 commit ce1eb0a

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

authority/tls.go

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -245,21 +245,10 @@ func (a *Authority) Rekey(oldCert *x509.Certificate, pk crypto.PublicKey) ([]*x5
245245
newCert.ExtraExtensions = append(newCert.ExtraExtensions, ext)
246246
}
247247

248-
leaf, err := x509legacy.NewLeafProfileWithTemplate(newCert, a.x509Issuer, a.x509Signer)
248+
serverCert, err := x509util.CreateCertificate(newCert, a.x509Issuer, newCert.PublicKey, a.x509Signer)
249249
if err != nil {
250250
return nil, errs.Wrap(http.StatusInternalServerError, err, "authority.Rekey", opts...)
251251
}
252-
crtBytes, err := leaf.CreateCertificate()
253-
if err != nil {
254-
return nil, errs.Wrap(http.StatusInternalServerError, err,
255-
"authority.Rekey; error renewing certificate from existing server certificate", opts...)
256-
}
257-
258-
serverCert, err := x509.ParseCertificate(crtBytes)
259-
if err != nil {
260-
return nil, errs.Wrap(http.StatusInternalServerError, err,
261-
"authority.Rekey; error parsing new server certificate", opts...)
262-
}
263252

264253
if err = a.db.StoreCertificate(serverCert); err != nil {
265254
if err != db.ErrNotImplemented {

authority/tls_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ func TestAuthority_Renew(t *testing.T) {
538538
return &renewTest{
539539
auth: _a,
540540
cert: cert,
541-
err: errors.New("authority.Rekey; error renewing certificate from existing server certificate"),
541+
err: errors.New("authority.Rekey: error creating certificate"),
542542
code: http.StatusInternalServerError,
543543
}, nil
544544
},
@@ -766,7 +766,7 @@ func TestAuthority_Rekey(t *testing.T) {
766766
return &renewTest{
767767
auth: _a,
768768
cert: cert,
769-
err: errors.New("authority.Rekey; error renewing certificate from existing server certificate"),
769+
err: errors.New("authority.Rekey: error creating certificate"),
770770
code: http.StatusInternalServerError,
771771
}, nil
772772
},

0 commit comments

Comments
 (0)