2017-08-08 12:28:17 -04:00
---
2020-01-17 19:18:09 -05:00
layout: api
page_title: TLS Certificate - Auth Methods - HTTP API
2017-08-08 12:28:17 -04:00
description: |-
This is the API documentation for the Vault TLS Certificate authentication
2017-09-12 21:48:52 -04:00
method.
2017-08-08 12:28:17 -04:00
---
2023-06-30 19:22:07 -04:00
# TLS certificate auth method (API)
2017-08-08 12:28:17 -04:00
2022-06-01 15:41:11 -04:00
@include 'x509-sha1-deprecation.mdx'
2017-09-12 21:48:52 -04:00
This is the API documentation for the Vault TLS Certificate authentication
method. For general information about the usage and operation of the TLS
2023-01-25 19:12:15 -05:00
Certificate method, please see the [Vault TLS Certificate method documentation](/vault/docs/auth/cert).
2017-08-08 12:28:17 -04:00
2017-09-12 21:48:52 -04:00
This documentation assumes the TLS Certificate method is mounted at the
2017-09-21 17:14:40 -04:00
`/auth/cert` path in Vault. Since it is possible to enable auth methods at any
2017-08-08 12:28:17 -04:00
location, please update your API calls accordingly.
2023-06-30 19:22:07 -04:00
## Create CA certificate role
2017-08-08 12:28:17 -04:00
Sets a CA cert and associated parameters in a role name.
2020-01-17 19:18:09 -05:00
| Method | Path |
| :----- | :----------------------- |
| `POST` | `/auth/cert/certs/:name` |
2017-08-08 12:28:17 -04:00
### Parameters
- `name` `(string: <required>)` - The name of the certificate role.
- `certificate` `(string: <required>)` - The PEM-format CA certificate.
2018-05-25 10:39:23 -04:00
- `allowed_names` `(string: "")` - DEPRECATED: Please use the individual
`allowed_X_sans` parameters instead. Constrain the Common and Alternative
2020-01-17 19:18:09 -05:00
Names in the client certificate with a [globbed pattern](https://github.com/ryanuber/go-glob/blob/master/README.md#example). Value is
2017-12-18 15:29:45 -05:00
a comma-separated list of patterns. Authentication requires at least one Name
matching at least one pattern. If not set, defaults to allowing all names.
2018-05-25 10:39:23 -04:00
- `allowed_common_names` `(string: "" or array: [])` - Constrain the Common
2020-01-17 19:18:09 -05:00
Names in the client certificate with a [globbed pattern](https://github.com/ryanuber/go-glob/blob/master/README.md#example). Value is
2018-05-25 10:34:46 -04:00
a comma-separated list of patterns. Authentication requires at least one Name
matching at least one pattern. If not set, defaults to allowing all names.
2018-05-25 10:39:23 -04:00
- `allowed_dns_sans` `(string: "" or array: [])` - Constrain the Alternative
2020-01-17 19:18:09 -05:00
Names in the client certificate with a [globbed pattern](https://github.com/ryanuber/go-glob/blob/master/README.md#example). Value is
2018-05-25 10:34:46 -04:00
a comma-separated list of patterns. Authentication requires at least one DNS
matching at least one pattern. If not set, defaults to allowing all dns.
2018-05-25 10:39:23 -04:00
- `allowed_email_sans` `(string: "" or array: [])` - Constrain the Alternative
2020-01-17 19:18:09 -05:00
Names in the client certificate with a [globbed pattern](https://github.com/ryanuber/go-glob/blob/master/README.md#example). Value is
2018-05-25 10:39:23 -04:00
a comma-separated list of patterns. Authentication requires at least one
Email matching at least one pattern. If not set, defaults to allowing all
emails.
- `allowed_uri_sans` `(string: "" or array: [])` - Constrain the Alternative
2020-01-17 19:18:09 -05:00
Names in the client certificate with a [globbed pattern](https://github.com/ryanuber/go-glob/blob/master/README.md#example). Value is
2018-05-25 10:39:23 -04:00
a comma-separated list of URI patterns. Authentication requires at least one
URI matching at least one pattern. If not set, defaults to allowing all URIs.
2018-09-27 20:04:55 -04:00
- `allowed_organizational_units` `(string: "" or array: [])` - Constrain the
2020-01-17 19:18:09 -05:00
Organizational Units (OU) in the client certificate with a [globbed pattern](https://github.com/ryanuber/go-glob/blob/master/README.md#example). Value is
2018-09-27 20:04:55 -04:00
a comma-separated list of OU patterns. Authentication requires at least one
OU matching at least one pattern. If not set, defaults to allowing all OUs.
2018-05-25 10:39:23 -04:00
- `required_extensions` `(string: "" or array: [])` - Require specific Custom
Extension OIDs to exist and match the pattern. Value is a comma separated
string or array of `oid:value`. Expects the extension value to be some type
2023-07-17 10:58:18 -04:00
of ASN1 encoded string. All conditions _must_ be met. To match on the hex-encoded
value of the extension, including non-string extensions, use the format
`hex:<oid>:<value>`.Supports globbing on `value`.
2022-12-12 13:08:00 -05:00
- `allowed_metadata_extensions` `(array:[])` - A comma separated string or
array of oid extensions. Upon successful authentication, these extensions
will be added as metadata if they are present in the certificate. The
metadata key will be the string consisting of the oid numbers separated
by a dash (-) instead of a dot (.) to allow usage in ACL templates.
2023-04-13 14:33:21 -04:00
- `ocsp_enabled` `(bool: false)` - If enabled, validate certificates' revocation
status using OCSP.
2024-10-09 16:16:26 -04:00
- `ocsp_ca_certificates` `(string: "")` Any additional OCSP responder certificates needed to
2023-04-13 14:33:21 -04:00
verify OCSP responses. Provided as base64 encoded PEM data.
- `ocsp_servers_override` `(array: [])`: A comma-separated list of OCSP server
addresses. If unset, the OCSP server is determined from the AuthorityInformationAccess
extension on the certificate being inspected.
- `ocsp_fail_open` `(bool: false)` - If true and an OCSP response cannot be fetched
or is of an unknown status, the login will proceed as if the certificate has not
been revoked.
2024-03-18 18:12:37 -04:00
- `ocsp_this_update_max_age` `(integer:0 or string: "")` - If greater than 0, specifies
the maximum age of an OCSP thisUpdate field. This avoids accepting old responses
without a nextUpdate field.
2024-03-19 10:39:37 -04:00
- `ocsp_max_retries` `(integer: 4)` - The number of retries attempted before giving
up on an OCSP request. 0 will disable retries
2023-04-13 14:33:21 -04:00
- `ocsp_query_all_servers` `(bool: false)` - If set to true, rather than accepting
the first successful OCSP response, query all servers and consider the certificate
valid only if all servers agree.
~> **Note**: When using Vault's PKI engine with Performance Replication clusters
as the OCSP provider, and without `unified_crls=true` set on the source mount
or when using cluster-local OCSP resolvers, we recommend enabling this option.
2017-12-18 15:29:45 -05:00
- `display_name` `(string: "")` - The `display_name` to set on tokens issued
2017-09-12 21:48:52 -04:00
when authenticating against this CA certificate. If not set, defaults to the
2017-08-08 12:28:17 -04:00
name of the role.
2019-07-30 15:58:32 -04:00
2020-12-17 16:53:33 -05:00
@include 'tokenfields.mdx'
2017-08-08 12:28:17 -04:00
2023-06-30 19:22:07 -04:00
### Sample payload
2017-08-08 12:28:17 -04:00
```json
{
"certificate": "-----BEGIN CERTIFICATE-----\nMIIEtzCCA5+.......ZRtAfQ6r\nwlW975rYa1ZqEdA=\n-----END CERTIFICATE-----",
2018-05-09 18:39:55 -04:00
"display_name": "test",
"bound_cidrs": ["127.0.0.1/32", "128.252.0.0/16"]
2017-08-08 12:28:17 -04:00
}
```
2023-06-30 19:22:07 -04:00
### Sample request
2017-08-08 12:28:17 -04:00
2020-05-21 13:18:17 -04:00
```shell-session
2017-08-08 12:28:17 -04:00
$ curl \
--header "X-Vault-Token: ..." \
--request POST \
2020-08-27 20:47:16 -04:00
--cacert vault-ca.pem \
2017-08-08 12:28:17 -04:00
--data @payload.json
2020-08-27 20:47:16 -04:00
https://127.0.0.1:8200/v1/auth/cert/certs/test-ca
2017-08-08 12:28:17 -04:00
```
2023-06-30 19:22:07 -04:00
## Read CA certificate role
2017-08-08 12:28:17 -04:00
Gets information associated with the named role.
2020-01-17 19:18:09 -05:00
| Method | Path |
| :----- | :----------------------- |
| `GET` | `/auth/cert/certs/:name` |
2017-08-08 12:28:17 -04:00
### Parameters
- `name` `(string: <required>)` - The name of the certificate role.
2023-06-30 19:22:07 -04:00
### Sample request
2017-08-08 12:28:17 -04:00
2020-05-21 13:18:17 -04:00
```shell-session
2017-08-08 12:28:17 -04:00
$ curl \
--header "X-Vault-Token: ..." \
2020-08-27 20:47:16 -04:00
--cacert vault-ca.pem \
https://127.0.0.1:8200/v1/auth/cert/certs/test-ca
2017-08-08 12:28:17 -04:00
```
2023-06-30 19:22:07 -04:00
### Sample response
2017-08-08 12:28:17 -04:00
```json
{
"lease_id": "",
"renewable": false,
"lease_duration": 0,
"data": {
"certificate": "-----BEGIN CERTIFICATE-----\nMIIEtzCCA5+.......ZRtAfQ6r\nwlW975rYa1ZqEdA=\n-----END CERTIFICATE-----",
"display_name": "test",
"policies": "",
"allowed_names": "",
2017-12-18 12:53:44 -05:00
"required_extensions": "",
2017-12-18 15:29:45 -05:00
"ttl": 2764800,
"max_ttl": 2764800,
"period": 0
2017-08-08 12:28:17 -04:00
},
"warnings": null,
"auth": null
}
```
2023-06-30 19:22:07 -04:00
## List certificate roles
2017-08-08 12:28:17 -04:00
Lists configured certificate names.
2020-01-17 19:18:09 -05:00
| Method | Path |
| :----- | :----------------- |
| `LIST` | `/auth/cert/certs` |
2017-08-08 12:28:17 -04:00
2023-06-30 19:22:07 -04:00
### Sample request
2017-08-08 12:28:17 -04:00
2020-05-21 13:18:17 -04:00
```shell-session
2017-08-08 12:28:17 -04:00
$ curl \
--header "X-Vault-Token: ..." \
--request LIST \
2020-08-27 20:47:16 -04:00
--cacert vault-ca.pem \
https://127.0.0.1:8200/v1/auth/cert/certs
2018-12-12 15:27:28 -05:00
```
2017-08-08 12:28:17 -04:00
2023-06-30 19:22:07 -04:00
### Sample response
2017-08-08 12:28:17 -04:00
```json
{
"auth": null,
"warnings": null,
"wrap_info": null,
"data": {
2020-01-17 19:18:09 -05:00
"keys": ["cert1", "cert2"]
2017-08-08 12:28:17 -04:00
},
"lease_duration": 0,
"renewable": false,
"lease_id": ""
}
```
2023-06-30 19:22:07 -04:00
## Delete certificate role
2017-08-08 12:28:17 -04:00
2017-09-12 21:48:52 -04:00
Deletes the named role and CA cert from the method mount.
2017-08-08 12:28:17 -04:00
2020-01-17 19:18:09 -05:00
| Method | Path |
| :------- | :----------------------- |
| `DELETE` | `/auth/cert/certs/:name` |
2017-08-08 12:28:17 -04:00
### Parameters
- `name` `(string: <required>)` - The name of the certificate role.
2023-06-30 19:22:07 -04:00
### Sample request
2017-08-08 12:28:17 -04:00
2020-05-21 13:18:17 -04:00
```shell-session
2017-08-08 12:28:17 -04:00
$ curl \
--header "X-Vault-Token: ..." \
--request DELETE \
2020-08-27 20:47:16 -04:00
--cacert vault-ca.pem \
https://127.0.0.1:8200/v1/auth/cert/certs/cert1
2017-08-08 12:28:17 -04:00
```
2022-11-18 11:39:17 -05:00
## List CRLs
Lists configured certificate revocation lists.
| Method | Path |
| :----- | :---------------- |
| `LIST` | `/auth/cert/crls` |
2023-06-30 19:22:07 -04:00
### Sample request
2022-11-18 11:39:17 -05:00
```shell-session
$ curl \
--header "X-Vault-Token: ..." \
--request LIST \
--cacert vault-ca.pem \
https://127.0.0.1:8200/v1/auth/cert/crls
```
2023-06-30 19:22:07 -04:00
### Sample response
2022-11-18 11:39:17 -05:00
```json
{
"auth": null,
"warnings": null,
"wrap_info": null,
"data": {
"keys": ["crl1", "crl2"]
},
"lease_duration": 0,
"renewable": false,
"lease_id": ""
}
```
2017-08-08 12:28:17 -04:00
## Create CRL
Sets a named CRL.
2020-01-17 19:18:09 -05:00
| Method | Path |
| :----- | :---------------------- |
| `POST` | `/auth/cert/crls/:name` |
2017-08-08 12:28:17 -04:00
2017-09-12 21:48:52 -04:00
### Parameters
2017-08-08 12:28:17 -04:00
- `name` `(string: <required>)` - The name of the CRL.
2023-07-27 11:09:17 -04:00
- `crl` `(string: "")` - The PEM format CRL.
- `url` `(string: "")` - The URL of a CRL distribution point.
**Note**: Either 'crl' or 'url' parameters must be provided, if both are provided, 'crl' is used.
2017-08-08 12:28:17 -04:00
2023-06-30 19:22:07 -04:00
### Sample payload
2017-08-08 12:28:17 -04:00
```json
{
"crl": "-----BEGIN X509 CRL-----\n...\n-----END X509 CRL-----"
}
```
2023-06-30 19:22:07 -04:00
### Sample request
2017-08-08 12:28:17 -04:00
2020-05-21 13:18:17 -04:00
```shell-session
2017-08-08 12:28:17 -04:00
$ curl \
--header "X-Vault-Token: ..." \
--request POST \
2020-08-27 20:47:16 -04:00
--cacert vault-ca.pem \
2019-04-19 01:20:46 -04:00
--data @payload.json \
2020-08-27 20:47:16 -04:00
https://127.0.0.1:8200/v1/auth/cert/crls/custom-crl
2017-08-08 12:28:17 -04:00
```
## Read CRL
Gets information associated with the named CRL (currently, the serial
2020-01-17 19:18:09 -05:00
numbers contained within). As the serials can be integers up to an
2017-08-08 12:28:17 -04:00
arbitrary size, these are returned as strings.
2020-01-17 19:18:09 -05:00
| Method | Path |
| :----- | :---------------------- |
| `GET` | `/auth/cert/crls/:name` |
2017-08-08 12:28:17 -04:00
### Parameters
- `name` `(string: <required>)` - The name of the CRL.
2023-06-30 19:22:07 -04:00
### Sample request
2017-08-08 12:28:17 -04:00
2020-05-21 13:18:17 -04:00
```shell-session
2017-08-08 12:28:17 -04:00
$ curl \
--header "X-Vault-Token: ..." \
2020-08-27 20:47:16 -04:00
--cacert vault-ca.pem \
https://127.0.0.1:8200/v1/auth/cert/crls/custom-crl
2017-08-08 12:28:17 -04:00
```
2023-06-30 19:22:07 -04:00
### Sample response
2017-08-08 12:28:17 -04:00
```json
{
"auth": null,
"data": {
"serials": {
"13": {}
}
},
"lease_duration": 0,
"lease_id": "",
"renewable": false,
"warnings": null
}
```
2017-09-07 10:28:14 -04:00
## Delete CRL
2017-08-08 12:28:17 -04:00
2017-09-12 21:48:52 -04:00
Deletes the named CRL from the auth method mount.
2017-08-08 12:28:17 -04:00
2020-01-17 19:18:09 -05:00
| Method | Path |
| :------- | :---------------------- |
| `DELETE` | `/auth/cert/crls/:name` |
2017-08-08 12:28:17 -04:00
### Parameters
- `name` `(string: <required>)` - The name of the CRL.
2023-06-30 19:22:07 -04:00
### Sample request
2017-08-08 12:28:17 -04:00
2020-05-21 13:18:17 -04:00
```shell-session
2017-08-08 12:28:17 -04:00
$ curl \
--header "X-Vault-Token: ..." \
--request DELETE \
2020-08-27 20:47:16 -04:00
--cacert vault-ca.pem \
https://127.0.0.1:8200/v1/auth/cert/crls/cert1
2017-08-08 12:28:17 -04:00
```
2023-06-30 19:22:07 -04:00
## Configure TLS certificate method
2017-08-08 12:28:17 -04:00
2017-09-12 21:48:52 -04:00
Configuration options for the method.
2017-08-08 12:28:17 -04:00
2020-01-17 19:18:09 -05:00
| Method | Path |
| :----- | :------------------ |
| `POST` | `/auth/cert/config` |
2017-08-08 12:28:17 -04:00
### Parameters
- `disable_binding` `(boolean: false)` - If set, during renewal, skips the
matching of presented client identity with the client identity used during
2017-09-12 21:48:52 -04:00
login.
2022-12-12 13:08:00 -05:00
- `enable_identity_alias_metadata` `(boolean: false)` - If set, metadata of
the certificate including the metadata corresponding to
`allowed_metadata_extensions` will be stored in the alias
2023-04-13 14:33:21 -04:00
- `ocsp_cache_size` `(int: 100)` - The size of the OCSP response LRU cache. Note
that this cache is used for all configured certificates.
2024-03-18 18:12:37 -04:00
- `role_cache_size` `(int: 200)` - The size of the role cache. Use `-1` to disable
2024-02-15 16:48:30 -05:00
role caching.
2017-08-08 12:28:17 -04:00
2023-06-30 19:22:07 -04:00
### Sample payload
2017-08-08 12:28:17 -04:00
```json
{
"disable_binding": true
}
```
2023-06-30 19:22:07 -04:00
### Sample request
2017-08-08 12:28:17 -04:00
2020-05-21 13:18:17 -04:00
```shell-session
2017-08-08 12:28:17 -04:00
$ curl \
--header "X-Vault-Token: ..." \
--request POST \
2020-08-27 20:47:16 -04:00
--cacert vault-ca.pem \
2019-04-19 01:20:46 -04:00
--data @payload.json \
2024-05-01 17:09:38 -04:00
https://127.0.0.1:8200/v1/auth/cert/config
2017-08-08 12:28:17 -04:00
```
2023-06-30 19:22:07 -04:00
## Login with TLS certificate method
2017-08-08 12:28:17 -04:00
Log in and fetch a token. If there is a valid chain to a CA configured in the
2018-02-16 17:42:29 -05:00
method and all role constraints are matched, a token will be issued. If the
certificate has DNS SANs in it, each of those will be verified. If Common Name
is required to be verified, then it should be a fully qualified DNS domain name
and must be duplicated as a DNS SAN (see
https://tools.ietf.org/html/rfc6125#section-2.3)
2017-08-08 12:28:17 -04:00
2020-01-17 19:18:09 -05:00
| Method | Path |
| :----- | :----------------- |
| `POST` | `/auth/cert/login` |
2017-08-08 12:28:17 -04:00
### Parameters
2017-09-12 21:48:52 -04:00
- `name` `(string: "")` - Authenticate against only the named certificate role,
2017-08-08 12:28:17 -04:00
returning its policy list if successful. If not set, defaults to trying all
certificate roles and returning any one that matches.
2023-06-30 19:22:07 -04:00
### Sample payload
2017-08-08 12:28:17 -04:00
```json
{
"name": "cert1"
}
```
2023-06-30 19:22:07 -04:00
### Sample request
2017-08-08 12:28:17 -04:00
2020-08-27 20:47:16 -04:00
~> **NOTE** The `--cacert` value used here is for the Vault TLS Listener CA
certificate, not the CA that issued the client authentication certificate. This
can be omitted if the CA used to issue the Vault server certificate is trusted
by the local system executing this command.
2020-05-21 13:18:17 -04:00
```shell-session
2017-08-08 12:28:17 -04:00
$ curl \
--request POST \
2020-08-27 20:47:16 -04:00
--cacert vault-ca.pem \
2019-07-05 18:36:20 -04:00
--cert cert.pem \
--key key.pem \
2019-04-19 01:20:46 -04:00
--data @payload.json \
2019-06-27 11:04:09 -04:00
https://127.0.0.1:8200/v1/auth/cert/login
2017-08-08 12:28:17 -04:00
```
2023-06-30 19:22:07 -04:00
### Sample response
2017-08-08 12:28:17 -04:00
```json
{
"auth": {
"client_token": "cf95f87d-f95b-47ff-b1f5-ba7bff850425",
2020-01-17 19:18:09 -05:00
"policies": ["web", "stage"],
2017-08-08 12:28:17 -04:00
"lease_duration": 3600,
2020-01-17 19:18:09 -05:00
"renewable": true
2017-08-08 12:28:17 -04:00
}
}
2017-09-12 21:48:52 -04:00
```