From e30d3594f8d8d4b296107c3e133111a2817208ab Mon Sep 17 00:00:00 2001 From: Richard Barnes Date: Sun, 31 May 2015 23:02:57 -0400 Subject: [PATCH] Put registration checks together --- ra/registration-authority.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/ra/registration-authority.go b/ra/registration-authority.go index 64e71dc6c67..efda825a843 100644 --- a/ra/registration-authority.go +++ b/ra/registration-authority.go @@ -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 { @@ -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