Vault as Consul Connect service mesh CA default TTL values
- Dominant language
- Go
- Stars
- 30.1k
- Forks
- 4.6k
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 39
Description
### Overview of the Issue
When configuring Vault as Connect service mesh CA in a new datacenter the `RotationPeriod` and `IntermediateCertTTL` are set to a default value of respectively `2160h` and `8760h` if not specified.
When changing the CA configuration on an existing Consul DC using a similar configuration these two values are not set.
### Reproduction Steps
#### New Consul DC
- Configure Vault as Connect CA from the beginning using this configuration file
```hcl
connect {
ca_provider = "vault"
ca_config {
address = "http://${VAULT_IP}:8200"
token = "password"
root_pki_path = "connect-root"
intermediate_pki_path = "connect-intermediate"
leaf_cert_ttl = "72h"
}
}
```
- Start Consul
- Verify CA configuration with `consul connect ca get-config`
```json
{
"Provider": "vault",
"Config": {
"Address": "http://172.19.0.2:8200",
"IntermediateCertTTL": "8760h",
"IntermediatePKIPath": "connect-intermediate",
"LeafCertTTL": "72h",
"RootPKIPath": "connect-root",
"RotationPeriod": "2160h",
"Token": "password"
},
"State": null,
"CreateIndex": 7,
"ModifyIndex": 7
}
```
#### Existing Consul DC
- Enable connect with embedded CA using this configuration file
```hcl
connect {
ca_provider = "consul"
}
```
- Start Consul
- Create configuration file for Connect CA
```json
{
"Provider": "vault",
"Config": {
"LeafCertTTL": "72h",
"Address": "http://172.19.0.2:8200",
"Token": "password",
"RootPKIPath": "connect-root",
"IntermediatePKIPath": "connect-intermediate"
},
"ForceWithoutCrossSigning": false
}
```
- Apply the configuration
```shell
$ consul connect ca set-config -config-file config-connect-ca-provider-vault.json
Configuration updated!
```
- Verify CA configuration with `consul connect ca get-config`
```json
{
"Provider": "vault",
"Config": {
"Address": "http://172.19.0.2:8200",
"IntermediatePKIPath": "connect-intermediate",
"LeafCertTTL": "72h",
"RootPKIPath": "connect-root",
"Token": "password"
},
"State": null,
"ForceWithoutCrossSigning": false,
"CreateIndex": 7,
"ModifyIndex": 5155
}
```
As visible from the output the `RotationPeriod` and `IntermediateCertTTL` values are not set.
### Workaround
Explicitly set the values for `RotationPeriod` and `IntermediateCertTTL` in the payload of the `set-config` command.
```json
{
"Provider": "vault",
"Config": {
"LeafCertTTL": "1h",
"Address": "http://172.19.0.2:8200",
"Token": "password",
"RootPKIPath": "connect-root",
"IntermediatePKIPath": "connect-intermediate",
"RotationPeriod": "2160h",
"IntermediateCertTTL": "8760h"
},
"ForceWithoutCrossSigning": false
}
```
### Consul info for both Client and Server
Server info
```
agent:
check_monitors = 0
check_ttls = 0
checks = 0
services = 0
build:
prerelease =
revision = 27de64da
version = 1.10.0
consul:
acl = enabled
bootstrap = false
known_datacenters = 1
leader = false
leader_addr = 172.19.0.4:8300
server = true
raft:
applied_index = 7323
commit_index = 7323
fsm_pending = 0
last_contact = 62.169287ms
last_log_index = 7323
last_log_term = 2
last_snapshot_index = 0
last_snapshot_term = 0
latest_configuration = [{Suffrage:Voter ID:ac4e8906-e843-d1a8-e000-4a13663035ab Address:172.19.0.6:8300} {Suffrage:Voter ID:982fa7ab-b3cc-63b9-d631-0f6d4ad3e0f0 Address:172.19.0.5:8300} {Suffrage:Voter ID:505f131c-715a-de7f-429e-18dacd37da1e Address:172.19.0.4:8300}]
latest_configuration_index = 0
num_peers = 2
protocol_version = 3
protocol_version_max = 3
protocol_version_min = 0
snapshot_version_max = 1
snapshot_version_min = 0
state = Follower
term = 2
runtime:
arch = amd64
cpu_count = 8
goroutines = 111
max_procs = 8
os = linux
version = go1.16.5
serf_lan:
coordinate_resets = 0
encrypted = true
event_queue = 0
event_time = 2
failed = 0
health_score = 0
intent_queue = 0
left = 0
member_time = 5
members = 5
query_queue = 0
query_time = 1
serf_wan:
coordinate_resets = 0
encrypted = true
event_queue = 0
event_time = 1
failed = 0
health_score = 0
intent_queue = 0
left = 0
member_time = 4
members = 3
query_queue = 0
query_time = 1
```
Contributor guide
Research direction
Reproduce the difference between configuring Vault as the CA at startup and applying the same configuration with `consul connect ca set-config`. Trace the two configuration paths and compare how `RotationPeriod` and `IntermediateCertTTL` are handled; done means both paths report the default values shown by `consul connect ca get-config`.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli, infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100