Skip to content

Commit

Permalink
Put registration checks together
Browse files Browse the repository at this point in the history
  • Loading branch information
bifurcation committed Jun 1, 2015
1 parent 129b05f commit e30d359
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions ra/registration-authority.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ func (ra *RegistrationAuthorityImpl) NewCertificate(req core.CertificateRequest,
return emptyCert, err
}

registration, err := ra.SA.GetRegistration(regID)
if err != nil {
logEvent.Error = err.Error()
return emptyCert, err
}

// Verify the CSR
csr := req.CSR
if err = core.VerifyCSR(csr); err != nil {
Expand Down Expand Up @@ -196,13 +202,6 @@ func (ra *RegistrationAuthorityImpl) NewCertificate(req core.CertificateRequest,
return emptyCert, err
}

registration, err := ra.SA.GetRegistration(regID)
if err != nil {
err = core.InternalServerError(err.Error())
logEvent.Error = err.Error()
return emptyCert, err
}

if core.KeyDigestEquals(csr.PublicKey, registration.Key) {
err = core.MalformedRequestError("Certificate public key must be different than account key")
return emptyCert, err
Expand Down

0 comments on commit e30d359

Please sign in to comment.