2015-04-17 19:56:03 +00:00
|
|
|
---
|
|
|
|
layout: "docs"
|
2015-04-28 18:32:04 +00:00
|
|
|
page_title: "Secret Backend: Transit"
|
2015-04-17 19:56:03 +00:00
|
|
|
sidebar_current: "docs-secrets-transit"
|
|
|
|
description: |-
|
|
|
|
The transit secret backend for Vault encrypts/decrypts data in-transit. It doesn't store any secrets.
|
|
|
|
---
|
|
|
|
|
|
|
|
# Transit Secret Backend
|
|
|
|
|
|
|
|
Name: `transit`
|
|
|
|
|
|
|
|
The transit secret backend is used to encrypt/data in-transit. Vault doesn't
|
|
|
|
store the data sent to the backend. It can also be viewed as "encryption as
|
|
|
|
a service."
|
|
|
|
|
|
|
|
The primary use case for the transit backend is to encrypt data from
|
|
|
|
applications while still storing that encrypted data in some primary data
|
|
|
|
store. This relieves the burden of proper encryption/decryption from
|
|
|
|
application developers and pushes the burden onto the operators of Vault.
|
|
|
|
Operators of Vault generally include the security team at an organization,
|
|
|
|
which means they can ensure that data is encrypted/decrypted properly.
|
|
|
|
|
|
|
|
Additionally, since encrypt/decrypt operations must enter the audit log,
|
|
|
|
any decryption event is recorded.
|
|
|
|
|
|
|
|
This page will show a quick start for this backend. For detailed documentation
|
|
|
|
on every path, use `vault help` after mounting the backend.
|
|
|
|
|
|
|
|
## Quick Start
|
|
|
|
|
2015-04-27 02:36:36 +00:00
|
|
|
The first step to using the transit backend is to mount it. Unlike the `generic`
|
|
|
|
backend, the `transit` backend is not mounted by default.
|
|
|
|
|
|
|
|
```
|
|
|
|
$ vault mount transit
|
|
|
|
Successfully mounted 'transit' at 'transit'!
|
|
|
|
```
|
|
|
|
|
|
|
|
The next step is to create a named encryption key. A named key is used so that
|
|
|
|
many different applications can use the transit backend with independent keys.
|
|
|
|
This is done by doing a write against the backend:
|
|
|
|
|
|
|
|
```
|
2015-04-27 20:52:47 +00:00
|
|
|
$ vault write transit/keys/foo test=1
|
|
|
|
Success! Data written to: transit/keys/foo
|
2015-04-27 02:36:36 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
This will create the "foo" named key in the transit backend. We can inspect
|
|
|
|
the settings of the "foo" key by reading it:
|
|
|
|
|
|
|
|
```
|
2015-04-27 20:52:47 +00:00
|
|
|
$ vault read transit/keys/foo
|
2015-04-27 02:36:36 +00:00
|
|
|
Key Value
|
|
|
|
name foo
|
|
|
|
cipher_mode aes-gcm
|
|
|
|
key PhKFTALCmhAhVQfMBAH4+UwJ6J2gybapUH9BsrtIgR8=
|
|
|
|
````
|
|
|
|
|
|
|
|
Here we can see that the randomly generated encryption key being used, as
|
|
|
|
well as the AES-GCM cipher mode. We don't need to know any of this to use
|
|
|
|
the key however.
|
|
|
|
|
|
|
|
Now, if we wanted to encrypt a piece of plain text, we use the encrypt
|
|
|
|
endpoint using our named key:
|
|
|
|
|
|
|
|
```
|
|
|
|
$ echo "the quick brown fox" | base64 | vault write transit/encrypt/foo plaintext=-
|
2015-04-27 21:58:53 +00:00
|
|
|
Key Value
|
|
|
|
ciphertext vault:v0:czEwyKqGZY/limnuzDCUUe5AK0tbBObWqeZgFqxCuIqq7A84SeiOq3sKD0Y/KUvv
|
2015-04-27 02:36:36 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
The encryption endpoint expects the plaintext to be provided as a base64 encoded
|
|
|
|
strings, so we must first convert it. Vault does not store the plaintext or the
|
|
|
|
ciphertext, but only handles it _in transit_ for processing. The application
|
|
|
|
is free to store the ciphertext in a database or file at rest.
|
|
|
|
|
|
|
|
To decrypt, we simply use the decrypt endpoint using the same named key:
|
|
|
|
|
|
|
|
```
|
2015-04-27 21:58:53 +00:00
|
|
|
$ vault write transit/decrypt/foo ciphertext=vault:v0:czEwyKqGZY/limnuzDCUUe5AK0tbBObWqeZgFqxCuIqq7A84SeiOq3sKD0Y/KUvv
|
|
|
|
Key Value
|
|
|
|
plaintext dGhlIHF1aWNrIGJyb3duIGZveAo=
|
|
|
|
|
2015-04-27 02:36:36 +00:00
|
|
|
$ echo "dGhlIHF1aWNrIGJyb3duIGZveAo=" | base64 -D
|
|
|
|
the quick brown fox
|
|
|
|
```
|
|
|
|
|
|
|
|
Using ACLs, it is possible to restrict using the transit backend such
|
|
|
|
that trusted operators can manage the named keys, and applications can
|
|
|
|
only encrypt or decrypt using the named keys they need access to.
|
|
|
|
|
|
|
|
## API
|
|
|
|
|
2015-04-27 20:52:47 +00:00
|
|
|
### /transit/keys/
|
2015-04-27 19:30:46 +00:00
|
|
|
#### POST
|
2015-04-27 02:36:36 +00:00
|
|
|
|
2015-04-27 19:30:46 +00:00
|
|
|
<dl class="api">
|
2015-04-27 02:36:36 +00:00
|
|
|
<dt>Description</dt>
|
|
|
|
<dd>
|
|
|
|
Creates a new named encryption key. This is a root protected endpoint.
|
|
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>Method</dt>
|
|
|
|
<dd>POST</dd>
|
|
|
|
|
|
|
|
<dt>URL</dt>
|
2015-04-27 20:52:47 +00:00
|
|
|
<dd>`/transit/keys/<name>`</dd>
|
2015-04-27 02:36:36 +00:00
|
|
|
|
|
|
|
<dt>Parameters</dt>
|
|
|
|
<dd>
|
|
|
|
None
|
|
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>Returns</dt>
|
|
|
|
<dd>
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"name": "foo",
|
|
|
|
"cipher_mode": "aes-gcm",
|
|
|
|
"key": "PhKFTALCmhAhVQfMBAH4+UwJ6J2gybapUH9BsrtIgR8="
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
</dd>
|
|
|
|
</dl>
|
|
|
|
|
2015-04-27 19:30:46 +00:00
|
|
|
#### GET
|
2015-04-27 02:36:36 +00:00
|
|
|
|
2015-04-27 19:30:46 +00:00
|
|
|
<dl class="api">
|
2015-04-27 02:36:36 +00:00
|
|
|
<dt>Description</dt>
|
|
|
|
<dd>
|
|
|
|
Returns information about a named encryption key.
|
|
|
|
This is a root protected endpoint.
|
|
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>Method</dt>
|
|
|
|
<dd>GET</dd>
|
|
|
|
|
|
|
|
<dt>URL</dt>
|
2015-04-27 20:52:47 +00:00
|
|
|
<dd>`/transit/keys/<name>`</dd>
|
2015-04-27 02:36:36 +00:00
|
|
|
|
|
|
|
<dt>Parameters</dt>
|
|
|
|
<dd>
|
|
|
|
None
|
|
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>Returns</dt>
|
|
|
|
<dd>
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"name": "foo",
|
|
|
|
"cipher_mode": "aes-gcm",
|
|
|
|
"key": "PhKFTALCmhAhVQfMBAH4+UwJ6J2gybapUH9BsrtIgR8="
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
</dd>
|
|
|
|
</dl>
|
|
|
|
|
2015-04-27 19:30:46 +00:00
|
|
|
#### DELETE
|
2015-04-27 02:36:36 +00:00
|
|
|
|
2015-04-27 19:30:46 +00:00
|
|
|
<dl class="api">
|
2015-04-27 02:36:36 +00:00
|
|
|
<dt>Description</dt>
|
|
|
|
<dd>
|
|
|
|
Deletes a named encryption key. This is a root protected endpoint.
|
|
|
|
All data encrypted with the named key will no longer be decryptable.
|
|
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>Method</dt>
|
|
|
|
<dd>DELETE</dd>
|
|
|
|
|
|
|
|
<dt>URL</dt>
|
2015-04-27 20:52:47 +00:00
|
|
|
<dd>`/transit/keys/<name>`</dd>
|
2015-04-27 02:36:36 +00:00
|
|
|
|
|
|
|
<dt>Parameters</dt>
|
|
|
|
<dd>
|
|
|
|
None
|
|
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>Returns</dt>
|
|
|
|
<dd>
|
|
|
|
A `204` response code.
|
|
|
|
</dd>
|
|
|
|
</dl>
|
|
|
|
|
2015-04-27 19:30:46 +00:00
|
|
|
### /transit/encrypt/
|
|
|
|
#### POST
|
2015-04-27 02:36:36 +00:00
|
|
|
|
2015-04-27 19:30:46 +00:00
|
|
|
<dl class="api">
|
2015-04-27 02:36:36 +00:00
|
|
|
<dt>Description</dt>
|
|
|
|
<dd>
|
|
|
|
Encrypts the provided plaintext using the named key.
|
|
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>Method</dt>
|
|
|
|
<dd>POST</dd>
|
|
|
|
|
|
|
|
<dt>URL</dt>
|
|
|
|
<dd>`/transit/encrypt/<name>`</dd>
|
|
|
|
|
|
|
|
<dt>Parameters</dt>
|
|
|
|
<dd>
|
|
|
|
<ul>
|
|
|
|
<li>
|
|
|
|
<span class="param">plaintext</span>
|
|
|
|
<span class="param-flags">required</span>
|
|
|
|
The plaintext to encrypt, provided as base64 encoded.
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>Returns</dt>
|
|
|
|
<dd>
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"ciphertext": "vault:v0:abcdefgh"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
</dd>
|
|
|
|
</dl>
|
|
|
|
|
2015-04-27 19:30:46 +00:00
|
|
|
### /transit/decrypt/
|
|
|
|
#### POST
|
2015-04-27 02:36:36 +00:00
|
|
|
|
2015-04-27 19:30:46 +00:00
|
|
|
<dl class="api">
|
2015-04-27 02:36:36 +00:00
|
|
|
<dt>Description</dt>
|
|
|
|
<dd>
|
2015-04-28 18:32:04 +00:00
|
|
|
Decrypts the provided ciphertext using the named key.
|
2015-04-27 02:36:36 +00:00
|
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>Method</dt>
|
|
|
|
<dd>POST</dd>
|
|
|
|
|
|
|
|
<dt>URL</dt>
|
|
|
|
<dd>`/transit/decrypt/<name>`</dd>
|
|
|
|
|
|
|
|
<dt>Parameters</dt>
|
|
|
|
<dd>
|
|
|
|
<ul>
|
|
|
|
<li>
|
|
|
|
<span class="param">ciphertext</span>
|
|
|
|
<span class="param-flags">required</span>
|
|
|
|
The ciphertext to decrypt, provided as returned by encrypt.
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>Returns</dt>
|
|
|
|
<dd>
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"plaintext": "dGhlIHF1aWNrIGJyb3duIGZveAo="
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
</dd>
|
|
|
|
</dl>
|