1
0
mirror of https://github.com/laurivosandi/certidude synced 2025-10-31 01:19:11 +00:00

Refactor request submission

API now properly distinguishes duplicate request from other requests with same common name.
This commit is contained in:
2016-01-14 11:02:57 +02:00
parent aacf94bb28
commit d8abde3d53
2 changed files with 17 additions and 5 deletions

View File

@@ -68,12 +68,17 @@ class RequestListResource(object):
# Attempt to save the request otherwise
try:
csr = authority.store_request(body)
except FileExistsError:
except authority.RequestExists:
# We should stil redirect client to long poll URL below
pass
except authority.DuplicateCommonNameError:
# TODO: Certificate renewal
logger.warning("Rejected signing request with overlapping common name from %s", req.env["REMOTE_ADDR"])
raise falcon.HTTPConflict(
"CSR with such CN already exists",
"Will not overwrite existing certificate signing request, explicitly delete CSR and try again")
push.publish("request-submitted", csr.common_name)
else:
push.publish("request-submitted", csr.common_name)
# Wait the certificate to be signed if waiting is requested
if req.get_param("wait"):