handleSignCertificate :: AppState -> SomeKeyPair -> ActionM ()
handleSignCertificate state key = do
  csrId    <- param "csrid"
  maybeCsr <- query' state $ RetrieveCSR csrId
  case maybeCsr of
    Nothing    -> serveError notFound404 "Could not find CSR"
    (Just csr) ->
      maybe (signAndRespond state csr key) (serveError conflict409)
            (checkSignable csr)
handleSignCertificate :: AppState -> SomeKeyPair -> ActionM ()
handleSignCertificate state key = do
  csrId    <- param "csrid"
  maybeCsr <- query' state $ RetrieveCSR csrId
  case maybeCsr of
    Nothing    -> serveError notFound404 "Could not find CSR"
    (Just csr) ->
      maybe (signAndRespond state csr key) (serveError conflict409)
            (checkSignable csr)
handleSignCertificate state key = do
  csrId    <- param "csrid"
  maybeCsr <- query' state $ RetrieveCSR csrId
  case maybeCsr of
    Nothing    -> serveError notFound404 "Could not find CSR"
    (Just csr) ->
      maybe (signAndRespond state csr key) (serveError conflict409)
            (checkSignable csr)