Hi,
Sorry for a late reply, I was away...
The linked issue is for adding a parameter to the "tidy" resource
to clean up manually revoked certificates (the thing I've been
testing).
I have installed Vault 0.10.4 and can't seem to make this work. I
may be missing the point here, but the behaviour is confusing. To
replicate, I've followed Setup/Usage steps from the Vault guide
here:
https://www.vaultproject.io/docs/secrets/pki/index.html
Steps to reproduce:
vault secrets enable pki
vault secrets tune -max-lease-ttl=8760h pki
vault write pki/root/generate/internal \
common_name=my-website.com \
ttl=8760h
vault write pki/config/urls \
issuing_certificates="https://my-vault.internal:8200/v1/pki/ca"
\
crl_distribution_points="https://my-vault.internal/v1/pki/crl"
vault write pki/roles/my-role \
allowed_domains=my-website.com \
allow_subdomains=true \
max_ttl=72h
vault write pki/issue/my-role \
common_name=www.my-website.com
The generated certificate's serial number in my case was:
72:03:d3:b5:fb:d9:8d:3a:b2:b1:af:1f:9a:51:3b:ea:01:e3:6a:ff
Running
vault list pki/certs
returns
Keys
----
3f-52-9e-c4-3c-3d-ef-9a-9b-64-5e-99-af-0d-cc-ed-8a-14-35-cd
72-03-d3-b5-fb-d9-8d-3a-b2-b1-af-1f-9a-51-3b-ea-01-e3-6a-ff
3f-52-.... is the auto-generated root cert.
Running
vault read
pki/cert/72-03-d3-b5-fb-d9-8d-3a-b2-b1-af-1f-9a-51-3b-ea-01-e3-6a-ff
returns the certificate data, with
revocation_time 0
If I examine CRL using
curl --header "X-Vault-Token: $token"
https://my-vault.internal:8200/v1/pki/crl/pem > crl.pem
openssl crl -inform PEM -in crl.pem -text
I see there are no revoked certificates.
Now, running
vault write pki/revoke
serial_number='72-03-d3-b5-fb-d9-8d-3a-b2-b1-af-1f-9a-51-3b-ea-01-e3-6a-ff'
returns
Key Value
--- -----
revocation_time 1535463416
revocation_time_rfc3339 2018-08-28T13:36:56.256644972Z
And running
vault read
pki/cert/72-03-d3-b5-fb-d9-8d-3a-b2-b1-af-1f-9a-51-3b-ea-01-e3-6a-ff
returns certificate data, this time with
revocation_time
set to 1535463416
If I use curl and openssl again to examine CRL, I can see the
certificate in the revoked certificates list.
After this, I would expect that tidying up the storage would
delete the certificate. So, I run:
vault write pki/tidy safety_buffer=1 tidy_cert_store=true
tidy_revocation_list=true tidy_revoked_certs=true
with a successful output:
Success! Data written to: pki/tidy
If I examine CRL yet again, there are no revoked certificates.
However, running
vault list pki/certs
I still get the certificate listed:
Keys
----
3f-52-9e-c4-3c-3d-ef-9a-9b-64-5e-99-af-0d-cc-ed-8a-14-35-cd
72-03-d3-b5-fb-d9-8d-3a-b2-b1-af-1f-9a-51-3b-ea-01-e3-6a-ff
If I run
vault read
pki/cert/72-03-d3-b5-fb-d9-8d-3a-b2-b1-af-1f-9a-51-3b-ea-01-e3-6a-ff
I get the certificate data, with
revocation_time set to
0 again.
Am I misunderstanding how Vault handles revoked/expired
certificates here or not using Vault commands correctly?
Thank you,
Marko