# Issue a client certificate from a CSR

Canonical page: https://docs.ovok.com/api/signals/issue-a-client-certificate-from-a-csr

`POST /v1/signals/certs/issue`

Issues a client certificate for your current project from a certificate signing request (CSR), and registers it. Calls into Signals may then present it, and must once `SIGNALS_MTLS_ENABLED` is on.

**Auth:** A client credential cannot issue a certificate for itself.
**Scope:** the caller's project (from the token).

## Behaviour

- Make a key and a CSR on your side, and send the CSR as PEM in `csr`. The private key never leaves your client.
- The key must be an EC key on P-256 or P-384 that names its curve, or an RSA key of at least 2048 bits, and the CSR's signature must verify. Otherwise 422 `CSR_NOT_ACCEPTED`, with the reason.
- Ovok's CA signs a certificate for client authentication only, valid for six months, or until the CA itself expires if that comes first. Its `notAfter` is in the answer. Its subject is `CN=<tenant id>` and its subject alternative name `urn:ovok:signals-tenant:<tenant id>`. Nothing else in the CSR is taken over.
- The certificate counts towards the project's two: a third answers 409 `CERTIFICATE_LIMIT_REACHED`.
- An environment with no CA set up to issue answers 501 `FEATURE_NOT_CONFIGURED`. If its CA has expired, Ovok registers nothing and answers 500 `INTERNAL_ERROR`.
- The answer is 201 with the registered certificate and its PEM in `certificate`, and `Location` names it.
- At 00:00 UTC, 14 days before the certificate expires, Ovok notifies the project's admins in the Console and mails them and its parent project's admins. A certificate registered closer to its expiry is mailed about at once; a removed one is not.
- To rotate: issue a new certificate, move your clients to it, then remove the old one.

## Example

```bash
openssl req -new -newkey ec -pkeyopt ec_paramgen_curve:prime256v1 -pkeyopt ec_param_enc:named_curve -nodes \
  -keyout client.key -out client.csr -subj "/CN=client"

curl -X POST 'https://api.sandbox.ovok.com/v1/signals/certs/issue' \
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3NjcyNjg4MDAsImV4cCI6MTc2NzI3MjQwMH0.Ql3B_ztDvctlyZ2z0vp4sl3ExXRQGkzmxdmTAqxNzZk' \
  -H 'Content-Type: application/json' \
  -d "{ \"csr\": $(jq -Rs . < client.csr) }" | jq -r .certificate > client.crt
```

**Who can call it:** a project admin. See [roles](/access-policies#who-can-call-a-route).