2018-12-19 08:22:49 +00:00
|
|
|
---
|
2020-09-01 15:14:13 +00:00
|
|
|
layout: commands
|
2020-04-07 18:55:19 +00:00
|
|
|
page_title: 'Commands: TLS CA Create'
|
2023-01-26 18:42:13 +00:00
|
|
|
description: |
|
|
|
|
The `consul tls ca create` command creates a self-signed certificate authority (CA) for TLS setup.
|
2018-12-19 08:22:49 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
# Consul TLS CA Create
|
|
|
|
|
|
|
|
Command: `consul tls ca create`
|
|
|
|
|
2023-01-30 17:26:56 +00:00
|
|
|
This command creates a self-signed CA to be used for Consul TLS setup.
|
2018-12-19 08:22:49 +00:00
|
|
|
|
2023-01-30 17:26:56 +00:00
|
|
|
## Examples
|
2018-12-19 08:22:49 +00:00
|
|
|
|
2023-01-30 17:26:56 +00:00
|
|
|
Create a CA:
|
2018-12-19 08:22:49 +00:00
|
|
|
|
2020-05-19 18:32:38 +00:00
|
|
|
```shell-session
|
2018-12-19 08:22:49 +00:00
|
|
|
$ consul tls ca create
|
|
|
|
==> Saved consul-ca.pem
|
|
|
|
==> Saved consul-ca-key.pem
|
|
|
|
```
|
|
|
|
|
2023-01-30 17:26:56 +00:00
|
|
|
Create a CA that signs certificates exclusively for the example.com domain:
|
|
|
|
|
|
|
|
```shell-session
|
|
|
|
$ consul tls ca create -name-constraint -domain example.com
|
|
|
|
==> Saved example.com-ca.pem
|
|
|
|
==> Saved example.com-ca-key.pem
|
|
|
|
```
|
|
|
|
|
2018-12-19 08:22:49 +00:00
|
|
|
## Usage
|
2020-04-07 18:55:19 +00:00
|
|
|
|
2023-01-30 17:26:56 +00:00
|
|
|
Usage: `consul tls ca create [options]`
|
2018-12-19 08:22:49 +00:00
|
|
|
|
2022-07-27 06:17:11 +00:00
|
|
|
#### Command Options
|
2018-12-19 08:22:49 +00:00
|
|
|
|
2020-05-18 17:01:14 +00:00
|
|
|
- `-additional-name-constraint=<value>` - Add name constraints for the CA.
|
|
|
|
Results in rejecting certificates for other DNS than specified. Can be used
|
|
|
|
multiple times. Only used in combination with `-name-constraint`.
|
|
|
|
|
2023-01-30 17:26:56 +00:00
|
|
|
- `-days=<int>` - Number of days the CA is valid for. Defaults to 1825 days (approximately 5 years).
|
2020-05-18 17:01:14 +00:00
|
|
|
|
2023-01-30 17:26:56 +00:00
|
|
|
- `-domain=<string>` - The DNS domain of the Consul cluster that agents are [configured](/consul/docs/agent/config/cli-flags#_domain) with.
|
|
|
|
Defaults to `consul`. Only used when `-name-constraint` is set.
|
|
|
|
Additional domains can be passed with `-additional-name-constraint`.
|
2020-05-18 17:01:14 +00:00
|
|
|
|
2023-01-30 17:26:56 +00:00
|
|
|
- `-name-constraint` - Enables [X.509 name constraints](https://www.rfc-editor.org/rfc/rfc5280#page-40) for the CA.
|
|
|
|
If used, the CA only signs certificates for localhost and the domains specified by `-domain` and `-additional-name-constraint`.
|
|
|
|
If Consul's UI is served over HTTPS in your deployment, add its DNS name with `-additional-constraint` as well. Defaults to `false`.
|
2021-02-11 21:38:12 +00:00
|
|
|
|
2023-01-30 17:26:56 +00:00
|
|
|
- `cluster-id` - ID of the Consul cluster. Sets the CA's URI with the SPIFFEID composed of the cluster ID and domain
|
|
|
|
(specified by `-domain` or `consul` by default).
|
2021-02-11 21:38:12 +00:00
|
|
|
|
|
|
|
- `common-name` - Common Name of CA. Defaults to Consul Agent CA.
|