# Certificates

To use a custom certificate instead of the automatically generated one from the default public certificate authority, create a certificate with the CLI:

<CodeTabs syncKey="cli-tool">

```ansi title="unikraft"
unikraft certificates create \
  --cn *.mydomain.com \
  --name mydomain-cert \
  --pkey /path/to/private.key \
  --chain /path/to/chain.pem
```

```ansi title="kraft"
kraft cloud cert create \
  --cn *.mydomain.com \
  --name mydomain-cert \
  --pkey /path/to/private.key \
  --chain /path/to/chain.pem
```

</CodeTabs>

The provided common name (CN) must match the one for which Unikraft Cloud issued the certificate.
It can also be a wildcard domain.

Use the CLI to view and manage certificates.
For example, to list certificates:

<CodeTabs syncKey="cli-tool">

```bash title="unikraft"
unikraft certificates list
```

```bash title="kraft"
kraft cloud cert ls
```

</CodeTabs>

You should see output like:

```text title=""
NAME                STATE  COMMON NAME     CREATED AT
mydomain.com-sa4x9  valid  mydomain.com    5 days ago
mydomain-cert       valid  *.mydomain.com  2 days ago
```

Retrieve full information about a certificate with:

<CodeTabs syncKey="cli-tool">

```bash title="unikraft"
unikraft certificates get mydomain.com-sa4x9
```

```bash title="kraft"
kraft cloud cert get mydomain.com-sa4x9
```

</CodeTabs>

You should see output like:

```ansi title=""
        uuid: b8160db9-7cba-4b80-9107-c4fe27529bf5
        name: mydomain.com-sa4x9
        state: [92mvalid[0m
  common name: mydomain.com
      subject: CN=mydomain.com
      issuer: CN=R3,O=Let's Encrypt,C=US
serial number: 0455BBAEC140EACBA5FEEAE6D817E73EF266
  not before: 2024-03-07T18:06:11Z
    not after: 2024-06-05T18:06:10Z
  created at: 2024-03-07T19:06:04Z
    services: wispy-moon-dpg6d54i
```

To remove a certificate, first remove any instances from the relevant service and then remove the service.
Remove the certificate with:

<CodeTabs syncKey="cli-tool">

```bash title="unikraft"
unikraft certificates delete mydomain.com-sa4x9
```

```bash title="kraft"
kraft cloud cert rm mydomain.com-sa4x9
```

</CodeTabs>

## Learn more

* The [CLI reference](/docs/cli/unikraft) and the [legacy CLI reference](/docs/cli/kraft/overview).
* Unikraft Cloud's [REST API reference](/api/platform/v1).
* Many more guides [here](/guides/bun).
