Add location header to /acme/new-reg if key is already in use
This commit is contained in:
		
							parent
							
								
									c41c0a6b41
								
							
						
					
					
						commit
						d9d537f7f4
					
				|  | @ -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 | ||||
| 	} | ||||
|  |  | |||
|  | @ -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
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue