certificates/docs/revocation.md

212 lines
7.6 KiB
Markdown
Raw Permalink Normal View History

2019-04-27 20:24:53 +00:00
# Revocation
**Active Revocation**: A certificate is no longer valid from the moment it has
2019-04-29 18:21:40 +00:00
been actively revoked. Clients are required to check against centralized
sources of certificate validity information (e.g. by using CRLs (Certificate
Revocation Lists) or OCSP (Online Certificate Status Protocol)) to
verify that certificates have not been revoked. Active Revocation requires
clients to take an active role in certificate validation for the benefit of
real time revocation.
2019-04-27 20:24:53 +00:00
**Passive Revocation**: A certificate that has been passively revoked can no
longer be renewed. It will still be valid for the remainder of it's validity period,
but cannot be prolonged. The benefit of passive revocation is that clients
2019-04-29 18:21:40 +00:00
can verify certificates in a simple, decentralized manner without relying on
centralized 3rd parties. Passive revocation works best with short
2019-04-27 20:24:53 +00:00
certificate lifetimes.
`step certificates` currently only supports passive revocation. Active revocation
is on our roadmap.
2019-04-29 20:41:21 +00:00
Run `step help ca revoke` from the command line for full documentation, list of
command line flags, and examples.
2019-04-27 20:24:53 +00:00
## How It Works
Certificates can be created and revoked through the `step cli`. Let's walk
2019-04-29 18:21:40 +00:00
through an example.
2019-04-27 20:24:53 +00:00
### Requirements
2019-04-29 18:21:40 +00:00
* `step` (>=v0.10.0) ([install instructions](../README.md#installation-guide))
2019-04-27 20:24:53 +00:00
2019-04-29 18:21:40 +00:00
### Let's Get To It
2019-04-27 20:24:53 +00:00
1. Bootstrap your PKI.
2019-04-29 18:21:40 +00:00
> If you've already done this before and you have a `$STEPPATH` with certs,
> secrets, and configuration files then you can move on to step 2.
2019-04-27 20:24:53 +00:00
2019-04-29 18:21:40 +00:00
Run `step ca init`.
2019-04-27 20:24:53 +00:00
2019-04-29 18:21:40 +00:00
<pre><code>
<b>$ step ca init --name "Local CA" --provisioner admin --dns localhost --address ":443"</b>
</code></pre>
2019-04-27 20:24:53 +00:00
2019-04-29 18:21:40 +00:00
Move on to step 3.
2019-04-27 20:24:53 +00:00
2019-04-29 18:21:40 +00:00
2. Configure a persistence layer in your `ca.json`.
2019-04-27 20:24:53 +00:00
2019-04-29 18:21:40 +00:00
> If you did step 1 with `step` v0.10.0 or greater then your db will
> have been configured in the previous step.
2019-04-27 20:24:53 +00:00
2019-04-29 18:21:40 +00:00
Get your full step path by running `echo $(step path)`. Now edit
your `ca.json` by adding the following stanza as a top-level attribute:
> Your `ca.json` should be in `$(step path)/config/ca.json`.
2019-04-27 20:24:53 +00:00
2019-04-29 18:21:40 +00:00
```
...
"db": {
"type": "badger",
"dataSource": "<full step path>/db"
},
...
```
2019-04-27 20:24:53 +00:00
2019-04-29 18:21:40 +00:00
Check out our [database documentation](./database.md) to see all available
database backends and adapters.
2019-04-27 20:24:53 +00:00
2019-04-29 18:21:40 +00:00
3. Run the CA
2019-04-27 20:24:53 +00:00
<pre><code>
2019-04-29 18:21:40 +00:00
<b>$ step-ca $(step path)/config/ca.json</b>
2019-04-27 20:24:53 +00:00
</code></pre>
2019-04-29 18:21:40 +00:00
4. Create a certificate for localhost
2019-04-27 20:24:53 +00:00
<pre><code>
<b>$ step ca certificate localhost localhost.crt localhost.key</b>
✔ Key ID: n2kqNhicCCqVxJidspCQrjXWBtGwsa9zk3eBObrViy8 (sebastian@smallstep.com)
✔ Please enter the password to decrypt the provisioner key:
✔ CA: https://ca.smallstep.com
✔ Certificate: localhost.crt
✔ Private Key: localhost.key
<b>$ step certificate inspect --short localhost.crt</b>
X.509v3 TLS Certificate (ECDSA P-256) [Serial: 2400...2409]
Subject: localhost
Issuer: Smallstep Intermediate CA
Provisioner: sebastian@smallstep.com [ID: n2kq...Viy8]
Valid from: 2019-04-23T22:55:54Z
to: 2019-04-24T22:55:54Z
</code></pre>
2019-04-29 18:21:40 +00:00
5. Renew the certificate (just to prove we can!)
2019-04-27 20:24:53 +00:00
<pre><code>
<b>$ step ca renew localhost.crt localhost.key</b>
✔ Would you like to overwrite localhost.crt [y/n]: y
Your certificate has been saved in localhost.crt.
# Make sure the from timestamp is "newer"
<b>$ step certificate inspect --short localhost.crt</b>
X.509v3 TLS Certificate (ECDSA P-256) [Serial: 5963...8406]
Subject: localhost
Issuer: Smallstep Intermediate CA
Provisioner: sebastian@smallstep.com [ID: n2kq...Viy8]
Valid from: 2019-04-23T22:57:50Z
to: 2019-04-24T22:57:50Z
</pre></code>
2019-04-29 18:21:40 +00:00
6. Now let's revoke the certificate
2019-04-27 20:24:53 +00:00
<pre><code>
<b>$ step certificate inspect --format=json localhost.crt | jq .serial_number</b>
"59636004850364466675608080466579278406"
# the serial number is unique
<b>$ step ca revoke 59636004850364466675608080466579278406</b>
✔ Key ID: n2kqNhicCCqVxJidspCQrjXWBtGwsa9zk3eBObrViy8 (sebastian@smallstep.com)
✔ Please enter the password to decrypt the provisioner key:
✔ CA: https://ca.smallstep.com
Certificate with Serial Number 59636004850364466675608080466579278406 has been revoked.
</pre></code>
2019-04-29 18:21:40 +00:00
7. Awesome! But did it work?
2019-04-27 20:24:53 +00:00
<pre><code>
<b>$ step ca renew localhost.crt localhost.key</b>
error renewing certificate: Unauthorized
# log trace from CA:
[...]
WARN[0569] duration="82.782µs" duration-ns=82782
error="renew: certificate has been revoked"
fields.time="2019-04-23T16:03:01-07:00" method=POST
name=ca path=/renew protocol=HTTP/1.1 referer=
remote-address=127.0.0.1 request-id=bivpj9a3q563rpjheh5g
size=40 status=401 user-agent=Go-http-client/1.1 user-id=
[...]
</pre></code>
2019-04-29 18:21:40 +00:00
8. Other ways to revoke a Certificate
2019-04-27 20:24:53 +00:00
2019-04-29 18:21:40 +00:00
Use the certificate and key. This method does not require a provisioner
because it uses the certificate and key to authenticate the request.
2019-04-27 20:24:53 +00:00
<pre><code>
<b>$ step ca revoke --cert localhost.crt --key localhost.key</b>
Certificate with Serial Number 59636004850364466675608080466579278406 has been revoked.
</pre></code>
Or, revoke a certificate in two steps by first creating a revocation token and
then exchanging that token in a revocation request.
<pre><code>
<b>$ TOKEN=$(step ca token --revoke 59636004850364466675608080466579278406)</b>
✔ Key ID: n2kqNhicCCqVxJidspCQrjXWBtGwsa9zk3eBObrViy8 (sebastian@smallstep.com)
✔ Please enter the password to decrypt the provisioner key:
<b>$ echo $TOKEN | step crypto jwt inspect --insecure</b>
{
"header": {
"alg": "ES256",
"kid": "uxEunU9UhUo96lRvKgpEtRevkzbN5Yq88AFFtb1nSGg",
"typ": "JWT"
},
"payload": {
"aud": "https://localhost:443/1.0/revoke",
"exp": 1556395590,
"iat": 1556395290,
"iss": "sebastian@smallstep.com",
"jti": "1f222fc1a22530b7bcd2a40d7308c566c8e49f90413bc350e07bfabc8002b79b",
"nbf": 1556395290,
"sha": "fef4c75a050e1f3a31175ca4f4fdb711cbef1efcd374fcae4700596604eb8e5a",
"sub": "59636004850364466675608080466579278406"
},
"signature": "M1wX0ea3VXwS5rIim0TgtcCXHDtvP1GWD15cJSvVkrHNO6XMYl6m3ZmnWdwMi976msv-n2GTG3h6dJ3j2ImdfQ"
}
<b>$ step ca revoke --token $TOKEN 59636004850364466675608080466579278406</b>
Certificate with Serial Number 59636004850364466675608080466579278406 has been revoked.
</pre></code>
Or, revoke a certificate in offline mode:
<pre><code>
<b>$ step ca revoke --offline 59636004850364466675608080466579278406</b>
Certificate with Serial Number 59636004850364466675608080466579278406 has been revoked.
<b>$ step ca revoke --offline --cert localhost.crt --key localhost.key</b>
Certificate with Serial Number 59636004850364466675608080466579278406 has been revoked.
</pre></code>
> NOTE: you can only revoke a certificate once. Any repeated attempts to revoke
> the same serial number will fail.
2019-04-29 20:41:21 +00:00
Run `step help ca revoke` from the command line for full documentation, list of
command line flags, and examples.
2019-04-29 18:21:40 +00:00
## What's next?
2019-04-27 20:24:53 +00:00
[Use TLS Everywhere](https://smallstep.com/blog/use-tls.html) and let us know
2019-04-29 18:21:40 +00:00
what you think of our tools. Get in touch over
2019-04-30 00:50:30 +00:00
[Twitter](twitter.com/smallsteplabs) or through our
2021-06-29 18:01:53 +00:00
[GitHub Discussions](https://github.com/smallstep/certificates/discussions) to find answers to frequently asked questions.
[Discord](https://bit.ly/step-discord) to chat with us in real time.
2019-04-27 20:24:53 +00:00
## Further Reading
* [Use TLS Everywhere](https://smallstep.com/blog/use-tls.html)
* [Everything you should know about certificates and PKI but are too afraid to ask](https://smallstep.com/blog/everything-pki.html)