Skip to content

Commit dfda497

Browse files
Renamed RenewOrRekey to Rekey
1 parent fe73154 commit dfda497

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

api/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ type Authority interface {
3636
Root(shasum string) (*x509.Certificate, error)
3737
Sign(cr *x509.CertificateRequest, opts provisioner.Options, signOpts ...provisioner.SignOption) ([]*x509.Certificate, error)
3838
Renew(peer *x509.Certificate) ([]*x509.Certificate, error)
39-
RenewOrRekey(peer *x509.Certificate, pk crypto.PublicKey) ([]*x509.Certificate, error)
39+
Rekey(peer *x509.Certificate, pk crypto.PublicKey) ([]*x509.Certificate, error)
4040
LoadProvisionerByCertificate(*x509.Certificate) (provisioner.Interface, error)
4141
LoadProvisionerByID(string) (provisioner.Interface, error)
4242
GetProvisioners(cursor string, limit int) (provisioner.List, string, error)

api/api_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ func (m *mockAuthority) Renew(cert *x509.Certificate) ([]*x509.Certificate, erro
613613
return []*x509.Certificate{m.ret1.(*x509.Certificate), m.ret2.(*x509.Certificate)}, m.err
614614
}
615615

616-
func (m *mockAuthority) RenewOrRekey(oldcert *x509.Certificate, pk crypto.PublicKey) ([]*x509.Certificate, error) {
616+
func (m *mockAuthority) Rekey(oldcert *x509.Certificate, pk crypto.PublicKey) ([]*x509.Certificate, error) {
617617
if m.renewOrRekey != nil {
618618
return m.renewOrRekey(oldcert, pk)
619619
}

api/rekey.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (h *caHandler) Rekey(w http.ResponseWriter, r *http.Request) {
4343
return
4444
}
4545

46-
certChain, err := h.Authority.RenewOrRekey(r.TLS.PeerCertificates[0], body.CsrPEM.CertificateRequest.PublicKey)
46+
certChain, err := h.Authority.Rekey(r.TLS.PeerCertificates[0], body.CsrPEM.CertificateRequest.PublicKey)
4747
if err != nil {
4848
WriteError(w, errs.Wrap(http.StatusInternalServerError, err, "cahandler.Rekey"))
4949
return

authority/tls.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,16 @@ func (a *Authority) Sign(csr *x509.CertificateRequest, signOpts provisioner.Opti
139139
// Renew creates a new Certificate identical to the old certificate, except
140140
// with a validity window that begins 'now'.
141141
func (a *Authority) Renew(oldCert *x509.Certificate) ([]*x509.Certificate, error) {
142-
return a.RenewOrRekey(oldCert, oldCert.PublicKey)
142+
return a.Rekey(oldCert, oldCert.PublicKey)
143143
}
144144

145145
// Func is used for renewing or rekeying based on the public key passed.
146-
func (a *Authority) RenewOrRekey(oldCert *x509.Certificate, pk crypto.PublicKey) ([]*x509.Certificate, error) {
146+
func (a *Authority) Rekey(oldCert *x509.Certificate, pk crypto.PublicKey) ([]*x509.Certificate, error) {
147147
opts := []interface{}{errs.WithKeyVal("serialNumber", oldCert.SerialNumber.String())}
148148

149149
// Check step provisioner extensions
150150
if err := a.authorizeRenew(oldCert); err != nil {
151-
return nil, errs.Wrap(http.StatusInternalServerError, err, "authority.RenewOrRekey", opts...)
151+
return nil, errs.Wrap(http.StatusInternalServerError, err, "authority.Rekey", opts...)
152152
}
153153

154154
// Durations
@@ -201,7 +201,7 @@ func (a *Authority) RenewOrRekey(oldCert *x509.Certificate, pk crypto.PublicKey)
201201
pubBytes, err := x509.MarshalPKIXPublicKey(pk)
202202
if err != nil {
203203
return nil, errs.Wrap(http.StatusInternalServerError, err,
204-
"authority.RenewOrRekey; error marshaling public key", opts...)
204+
"authority.Rekey; error marshaling public key", opts...)
205205
}
206206
hash := sha1.Sum(pubBytes)
207207
skiExtension := pkix.Extension{
@@ -214,23 +214,23 @@ func (a *Authority) RenewOrRekey(oldCert *x509.Certificate, pk crypto.PublicKey)
214214

215215
leaf, err := x509util.NewLeafProfileWithTemplate(newCert, a.x509Issuer, a.x509Signer)
216216
if err != nil {
217-
return nil, errs.Wrap(http.StatusInternalServerError, err, "authority.RenewOrRekey", opts...)
217+
return nil, errs.Wrap(http.StatusInternalServerError, err, "authority.Rekey", opts...)
218218
}
219219
crtBytes, err := leaf.CreateCertificate()
220220
if err != nil {
221221
return nil, errs.Wrap(http.StatusInternalServerError, err,
222-
"authority.RenewOrRekey; error renewing certificate from existing server certificate", opts...)
222+
"authority.Rekey; error renewing certificate from existing server certificate", opts...)
223223
}
224224

225225
serverCert, err := x509.ParseCertificate(crtBytes)
226226
if err != nil {
227227
return nil, errs.Wrap(http.StatusInternalServerError, err,
228-
"authority.RenewOrRekey; error parsing new server certificate", opts...)
228+
"authority.Rekey; error parsing new server certificate", opts...)
229229
}
230230

231231
if err = a.db.StoreCertificate(serverCert); err != nil {
232232
if err != db.ErrNotImplemented {
233-
return nil, errs.Wrap(http.StatusInternalServerError, err, "authority.RenewOrRekey; error storing certificate in db", opts...)
233+
return nil, errs.Wrap(http.StatusInternalServerError, err, "authority.Rekey; error storing certificate in db", opts...)
234234
}
235235
}
236236

authority/tls_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ ZYtQ9Ot36qc=
370370
}
371371
}
372372

373-
func TestAuthority_RenewOrRekey(t *testing.T) {
373+
func TestAuthority_Rekey(t *testing.T) {
374374
pub, _, err := keys.GenerateDefaultKeyPair()
375375
assert.FatalError(t, err)
376376
pub1, _, err := keys.GenerateDefaultKeyPair()
@@ -430,14 +430,14 @@ func TestAuthority_RenewOrRekey(t *testing.T) {
430430
return &renewTest{
431431
auth: _a,
432432
cert: cert,
433-
err: errors.New("authority.RenewOrRekey; error renewing certificate from existing server certificate"),
433+
err: errors.New("authority.Rekey; error renewing certificate from existing server certificate"),
434434
code: http.StatusInternalServerError,
435435
}, nil
436436
},
437437
"fail-unauthorized": func() (*renewTest, error) {
438438
return &renewTest{
439439
cert: certNoRenew,
440-
err: errors.New("authority.RenewOrRekey: authority.authorizeRenew: jwk.AuthorizeRenew; renew is disabled for jwk provisioner dev:IMi94WBNI6gP5cNHXlZYNUzvMjGdHyBRmFoo-lCEaqk"),
440+
err: errors.New("authority.Rekey: authority.authorizeRenew: jwk.AuthorizeRenew; renew is disabled for jwk provisioner dev:IMi94WBNI6gP5cNHXlZYNUzvMjGdHyBRmFoo-lCEaqk"),
441441
code: http.StatusUnauthorized,
442442
}, nil
443443
},
@@ -480,9 +480,9 @@ func TestAuthority_RenewOrRekey(t *testing.T) {
480480

481481
var certChain []*x509.Certificate
482482
if tc.auth != nil {
483-
certChain, err = tc.auth.RenewOrRekey(tc.cert, pub1)
483+
certChain, err = tc.auth.Rekey(tc.cert, pub1)
484484
} else {
485-
certChain, err = a.RenewOrRekey(tc.cert, pub1)
485+
certChain, err = a.Rekey(tc.cert, pub1)
486486
}
487487
if err != nil {
488488
if assert.NotNil(t, tc.err, fmt.Sprintf("unexpected error: %s", err)) {

0 commit comments

Comments
 (0)