Add location header to /acme/new-reg if key is already in use

This commit is contained in:
Roland Shoemaker 2015-07-06 18:40:40 +01:00
parent c41c0a6b41
commit d9d537f7f4
2 changed files with 5 additions and 1 deletions

View File

@ -338,8 +338,9 @@ func (wfe *WebFrontEndImpl) NewRegistration(response http.ResponseWriter, reques
return
}
if _, err = wfe.SA.GetRegistrationByKey(*key); err == nil {
if existingReg, err := wfe.SA.GetRegistrationByKey(*key); err == nil {
logEvent.Error = "Registration key is already in use"
response.Header().Set("Location", fmt.Sprintf("%s%d", wfe.RegBase, existingReg.ID))
wfe.sendError(response, logEvent.Error, nil, http.StatusConflict)
return
}

View File

@ -703,6 +703,9 @@ func TestNewRegistration(t *testing.T) {
test.AssertEquals(t,
responseWriter.Body.String(),
"{\"type\":\"urn:acme:error:malformed\",\"detail\":\"Registration key is already in use\"}")
test.AssertEquals(
t, responseWriter.Header().Get("Location"),
"/acme/reg/1")
}
// Valid revocation request for existing, non-revoked cert