signAndRespond :: AppState -> CSR -> SomeKeyPair -> ActionM ()
signAndRespond state csr key = do
  ca   <- update' state GetNextSerialNumber
  cert <- liftIO $ signCSR csr ca key
  update' state $ SetSignedCSR (csr ^. requestId) $ cert ^. certId
  update' state $ InsertCertificate cert
  json cert
signAndRespond :: AppState -> CSR -> SomeKeyPair -> ActionM ()
signAndRespond state csr key = do
  ca   <- update' state GetNextSerialNumber
  cert <- liftIO $ signCSR csr ca key
  update' state $ SetSignedCSR (csr ^. requestId) $ cert ^. certId
  update' state $ InsertCertificate cert
  json cert
signAndRespond state csr key = do
  ca   <- update' state GetNextSerialNumber
  cert <- liftIO $ signCSR csr ca key
  update' state $ SetSignedCSR (csr ^. requestId) $ cert ^. certId
  update' state $ InsertCertificate cert
  json cert