New Vault OSS Now Includes Multi-factor Authentication! Learn more
  • Overview
    • Automated PKI Infrastructure
    • Data Encryption & Tokenization
    • Database Credential Rotation
    • Dynamic Secrets
    • Identity-based Access
    • Key Management
    • Kubernetes Secrets
    • Secrets Management
  • Enterprise
  • Tutorials
  • Docs
  • API
  • Community
GitHubTry Cloud
Download
    • v1.10.x (latest)
    • v1.9.x
    • v1.8.x
    • v1.7.x
    • v1.6.x
    • v1.5.x
    • v1.4.x
  • What is Vault?
  • Use Cases
    • CLI Quick Start
    • HCP Quick Start
    • Developer Quick Start

  • Browser Support
  • Installing Vault
    • Overview
    • Architecture
    • High Availability
    • Integrated Storage
    • Security Model
    • Telemetry
    • Token Authentication
    • Key Rotation
    • Replication
    • Limits and Maximums
    • Overview
    • 'Dev' Server
    • Seal/Unseal
    • Namespace API Lock
    • Lease, Renew, and Revoke
    • Authentication
    • Tokens
    • Identity
    • OIDC Provider
    • Response Wrapping
    • Policies
    • Password Policies
    • Username Templating
    • High Availability
    • Storage
      • Overview
      • Autopilot
    • PGP, GnuPG, and Keybase
    • Recovery Mode
    • Resource Quotas
      • Overview
      • FAQ
    • Transform
    • Mount Migration
    • Overview
      • Overview
      • TCP
    • replication
      • Overview
      • AliCloud KMS
      • AWS KMS
      • Azure Key Vault
      • GCP Cloud KMS
      • OCI KMS
      • HSM PKCS11 ENT
      • Vault Transit
    • sentinel
      • Overview
      • Consul
      • Kubernetes
      • Overview
      • Aerospike
      • Alicloud OSS
      • Azure
      • Cassandra
      • CockroachDB
      • Consul
      • CouchDB
      • DynamoDB
      • Etcd
      • Filesystem
      • FoundationDB
      • Google Cloud Spanner
      • Google Cloud Storage
      • In-Memory
      • Manta
      • MSSQL
      • MySQL
      • OCI Object Storage
      • PostgreSQL
      • Integrated Storage (Raft)
      • S3
      • Swift
      • Zookeeper
    • telemetry
    • ui
    • Log Completed Requests
    • Entropy Augmentation ENT
    • kms_library ENT
    • Overview
    • agent
      • Overview
      • disable
      • enable
      • list
      • Overview
      • disable
      • enable
      • help
      • list
      • move
      • tune
    • debug
    • delete
      • Overview
      • delete
      • destroy
      • enable-versioning
      • get
      • list
      • metadata
      • patch
      • put
      • rollback
      • undelete
      • Overview
      • lookup
      • renew
      • revoke
      • Overview
      • get
      • inspect
    • list
    • login
    • monitor
    • namespace
      • Overview
      • diagnose
      • generate-root
      • init
      • key-status
      • members
      • migrate
      • raft
      • rekey
      • rotate
      • seal
      • step-down
      • unseal
      • usage
    • path-help
      • Overview
      • deregister
      • info
      • list
      • register
      • reload
      • Overview
      • delete
      • fmt
      • list
      • read
      • write
    • read
      • Overview
      • disable
      • enable
      • list
      • move
      • tune
    • server
    • ssh
    • status
      • Overview
      • capabilities
      • create
      • lookup
      • renew
      • revoke
    • unwrap
    • version
    • version-history
    • write
    • Token Helpers
    • Overview
      • Overview
        • Overview
        • AliCloud
        • AppRole
        • AWS
        • Azure
        • Cert
        • CF
        • GCP
        • JWT
        • Kerberos
        • Kubernetes
        • Overview
        • File
      • Overview
        • Overview
        • Kubernetes
    • Templates
    • Windows service

    • Overview
    • Active Directory
    • AliCloud
    • AWS
    • Azure
    • Consul
    • Cubbyhole
      • Overview
      • Cassandra
      • Couchbase
      • Elasticsearch
      • HanaDB
      • IBM Db2
      • InfluxDB
      • MongoDB
      • MongoDB Atlas
      • MSSQL
      • MySQL/MariaDB
      • Oracle
      • PostgreSQL
      • Redshift
      • Snowflake
      • Custom
    • Google Cloud
    • Google Cloud KMS
      • Overview
      • Azure Key Vault
      • AWS KMS
      • GCP Cloud KMS
    • KMIP ENTERPRISE
      • Overview
      • K/V Version 1
      • K/V Version 2
      • Overview
      • Identity Tokens
      • OIDC Identity Provider
    • MongoDB Atlas
    • Nomad
    • OpenLDAP
    • PKI (Certificates)
    • RabbitMQ
      • Overview
      • Signed Certificates
      • SSH OTP
      • Dynamic Key
    • Terraform Cloud
    • TOTP
      • Overview
      • FF3-1 Tweak Usage
      • Tokenization Transform ENTERPRISE
    • Transit
    • Venafi (Certificates)
    • Overview
    • AppRole
    • AliCloud
    • AWS
    • Azure
    • Cloud Foundry
    • GitHub
    • Google Cloud
      • Overview
      • OIDC Providers
    • Kerberos
    • Kubernetes
    • LDAP
      • Overview
      • FAQ
    • Oracle Cloud Infrastructure
    • Okta
    • RADIUS
    • TLS Certificates
    • Tokens
    • Username & Password

    • App ID DEPRECATED
    • MFA LEGACY / UNSUPPORTED
    • Overview
    • File
    • Syslog
    • Socket
    • Overview
    • Plugin Architecture
    • Plugin Development
    • Plugin Management
    • Plugin Portal
  • Vault Integration Program
  • Troubleshoot

    • Overview
      • Overview
      • Agent Injector vs. Vault CSI Provider
        • Overview
        • Running Vault
        • Enterprise Licensing
        • Running Vault on OpenShift
        • Configuration
          • Overview
          • Development
          • Standalone with Load Balanced UI
          • Standalone with TLS
          • Standalone with Audit Storage
          • External Vault
          • Using Kubernetes Auth Method
          • HA Cluster with Consul
          • HA Cluster with Raft
          • HA Enterprise Cluster with Raft
          • HA Enterprise DR Clusters with Raft
          • HA Enterprise Performance Clusters with Raft
          • Vault Agent Injector TLS Configuration
          • Vault Agent Injector TLS with Cert-Manager
        • Overview
        • Annotations
        • Installation
        • Examples
        • Overview
        • Installation
        • Configurations
        • Examples
      • Overview
      • Vault Lambda Extension
      • Running Vault
      • Overview
      • Installation
      • Configuration
      • Troubleshooting
      • Overview
      • Installation
      • Troubleshooting

    • Overview
    • Upgrade Plugins
    • Upgrade to 1.10.x
    • Upgrade to 1.9.x
    • Upgrade to 1.8.x
    • Upgrade to 1.7.x
    • Upgrade to 1.6.3
    • Upgrade to 1.6.2
    • Upgrade to 1.6.1
    • Upgrade to 1.6.0
    • Upgrade to 1.5.3
    • Upgrade to 1.5.2
    • Upgrade to 1.5.1
    • Upgrade to 1.5.0
    • Upgrade to 1.4.6
    • Upgrade to 1.4.5
    • Upgrade to 1.4.4
    • Upgrade to 1.4.1
    • Upgrade to 1.4.0
    • Upgrade to 1.3.10
    • Upgrade to 1.3.9
    • Upgrade to 1.3.8
    • Upgrade to 1.3.5
    • Upgrade to 1.3.4
    • Upgrade to 1.3.3
    • Upgrade to 1.3.2
    • Upgrade to 1.3.0
    • Upgrade to 1.2.7
    • Upgrade to 1.2.6
    • Upgrade to 1.2.5
    • Upgrade to 1.2.4
    • Upgrade to 1.2.1
    • Upgrade to 1.2.0
    • Upgrade to 1.1.2
    • Upgrade to 1.1.1
    • Upgrade to 1.1.0
    • Upgrade to 1.0.0
    • Upgrade to 0.11.6
    • Upgrade to 0.11.2
    • Upgrade to 0.11.0
    • Upgrade to 0.10.4
    • Upgrade to 0.10.2
    • Upgrade to 0.10.0
    • Upgrade to 0.9.6
    • Upgrade to 0.9.3
    • Upgrade to 0.9.2
    • Upgrade to 0.9.1
    • Upgrade to 0.9.0
    • Upgrade to 0.8.0
    • Upgrade to 0.7.0
    • Upgrade to 0.6.4
    • Upgrade to 0.6.3
    • Upgrade to 0.6.2
    • Upgrade to 0.6.1
    • Upgrade to 0.6.0
    • Upgrade to 0.5.1
    • Upgrade to 0.5.0

    • Overview
    • 1.10.0
    • 1.9.0
    • 1.8.0
    • 1.7.0
    • 1.6.0
    • 1.5.0

    • Overview
    • FAQ

    • Overview
    • Feature Deprecation Notice and Plans
    • License
    • Client Count
    • Login MFA
    • Server Side Consistent Token

  • Glossary

    • Overview
      • Overview
      • Autoloading
      • FAQ
    • Replication
      • Overview
      • Behavioral Changes
      • Security
    • Automated Integrated Storage Snapshots
    • Lease Count Quotas
    • Entropy Augmentation
    • Seal Wrap / FIPS 140-2
    • Namespaces
    • Performance Standbys
    • Eventual Consistency
    • Control Groups
    • Managed Keys
      • Overview
      • Duo MFA
      • Okta MFA
      • PingID MFA
      • TOTP MFA
      • Overview
      • Examples
      • Properties
    • HCP Vault
Type '/' to Search

»Key Management Secrets Engine

Note: This secrets engine requires Vault Enterprise (1.6.0+) with the Advanced Data Protection KMSE Module.

The Key Management secrets engine provides a consistent workflow for distribution and lifecycle management of cryptographic keys in various key management service (KMS) providers. It allows organizations to maintain centralized control of their keys in Vault while still taking advantage of cryptographic capabilities native to the KMS providers.

The secrets engine generates and owns original copies of key material. When an operator decides to distribute and manage the lifecycle of a key in one of the supported KMS providers, a copy of the key material is distributed. This provides additional durability and disaster recovery means for the complete lifecycle of the key in the KMS provider.

Key material will always be securely transferred in accordance with the key import specification of the supported KMS providers.

»Setup

Most secrets engines must be configured in advance before they can perform their functions. These steps are usually completed by an operator or configuration management tool.

  1. Enable the Key Management secrets engine:

    $ vault secrets enable keymgmt
    Success! Enabled the keymgmt secrets engine at: keymgmt/
    
    $ vault secrets enable keymgmt
    Success! Enabled the keymgmt secrets engine at: keymgmt/
    

    By default, the secrets engine will mount at the name of the engine. To enable the secrets engine at a different path, use the -path argument.

»Usage

After the secrets engine is mounted and a user/machine has a Vault token with the proper permission, it can use this secrets engine to generate, distribute, and manage the lifecycle of cryptographic keys in supported KMS providers.

  1. Create a named cryptographic key of a specified type:

    $ vault write -f keymgmt/key/example-key type="rsa-2048"
    Success! Data written to: keymgmt/key/example-key
    
    $ vault write -f keymgmt/key/example-key type="rsa-2048"
    Success! Data written to: keymgmt/key/example-key
    

    Keys created by the secrets engine are considered general-purpose until they're distributed to a KMS provider.

  2. Configure a KMS provider:

    $ vault write keymgmt/kms/example-kms \
        provider="azurekeyvault" \
        key_collection="keyvault-name" \
        credentials=client_id="a0454cd1-e28e-405e-bc50-7477fa8a00b7" \
        credentials=client_secret="eR%HizuCVEpAKgeaUEx" \
        credentials=tenant_id="cd4bf224-d114-4f96-9bbc-b8f45751c43f"
    
    $ vault write keymgmt/kms/example-kms \
        provider="azurekeyvault" \
        key_collection="keyvault-name" \
        credentials=client_id="a0454cd1-e28e-405e-bc50-7477fa8a00b7" \
        credentials=client_secret="eR%HizuCVEpAKgeaUEx" \
        credentials=tenant_id="cd4bf224-d114-4f96-9bbc-b8f45751c43f"
    

    Conceptually, a KMS provider resource represents a destination for keys to be distributed to and subsequently managed in. It is configured using a generic set of parameters. The values supplied to the generic set of parameters will differ depending on the specified provider.

    This operation creates a KMS provider that represents a named Azure Key Vault instance. This is accomplished by specifying the azurekeyvault provider along with other provider-specific parameter values. For details on how to configure each supported KMS provider, see the KMS Providers section.

  3. Distribute a key to a KMS provider:

    $ vault write keymgmt/kms/example-kms/key/example-key \
        purpose="encrypt,decrypt" \
        protection="hsm"
    
    $ vault write keymgmt/kms/example-kms/key/example-key \
        purpose="encrypt,decrypt" \
        protection="hsm"
    

    This operation distributes a copy of the named key to the KMS provider with a specific purpose and protection. The purpose defines the set of cryptographic capabilities that the key will have in the KMS provider. The protection defines where cryptographic operations are performed with the key in the KMS provider. See the API documentation for a list of supported purpose and protection values.

    Note: The amount of time it takes to distribute a key to a KMS provider is proportional to the number of versions that the key has. If a timeout occurs when distributing a key to a KMS provider, you may need to increase the VAULT_CLIENT_TIMEOUT.

  4. Rotate a key:

    $ vault write -f keymgmt/key/example-key/rotate
    
    $ vault write -f keymgmt/key/example-key/rotate
    

    Rotating a key creates a new key version that contains new key material. The key will be rotated in both Vault and the KMS provider that the key has been distributed to. The new key version will be enabled and set as the current version for cryptographic operations in the KMS provider.

  5. Enable or disable key versions:

    $ vault write keymgmt/key/example-key min_enabled_version=2
    
    $ vault write keymgmt/key/example-key min_enabled_version=2
    

    The min_enabled_version of a key can be updated in order to enable or disable sequences of key versions. All versions of the key less than the min_enabled_version will be disabled for cryptographic operations in the KMS provider that the key has been distributed to. Setting a min_enabled_version of 0 means that all key versions will be enabled.

  6. Remove a key from a KMS provider:

    $ vault delete keymgmt/kms/example-kms/key/example-key
    
    $ vault delete keymgmt/kms/example-kms/key/example-key
    

    This operation results in the key being deleted from the KMS provider. The key will still exist in the secrets engine and can be redistributed to a KMS provider at a later time.

    To permanently delete the key from the secrets engine, the delete key API may be invoked.

»Key Types

The Key Management secrets engine supports generation of the following key types:

  • aes256-gcm96 - AES-GCM with a 256-bit AES key and a 96-bit nonce (symmetric)
  • rsa-2048 - RSA with bit size of 2048 (asymmetric)
  • rsa-3072 - RSA with bit size of 3072 (asymmetric)
  • rsa-4096 - RSA with bit size of 4096 (asymmetric)
  • ecdsa-p256 - ECDSA using the P-256 elliptic curve (asymmetric)
  • ecdsa-p384 - ECDSA using the P-384 elliptic curve (asymmetric)
  • ecdsa-p521 - ECDSA using the P-521 elliptic curve (asymmetric)

»KMS Providers

The Key Management secrets engine supports lifecycle management of keys in the following KMS providers:

  • Azure Key Vault
  • AWS KMS
  • GCP Cloud KMS

Refer to the provider-specific documentation for details on how to properly configure each provider.

»Compatibility

The following table defines which key types are compatible with each KMS provider.

Key TypeAzure Key VaultAWS KMSGCP Cloud KMS
aes256-gcm96NoYesYes
rsa-2048YesNoYes
rsa-3072YesNoYes
rsa-4096YesNoYes
ecdsa-p256NoNoYes
ecdsa-p384NoNoYes
ecdsa-p521NoNoNo

»Tutorial

Refer to the Key Management Secrets Engine tutorial series to learn how to use the key management secrets engine for Azure and GCP.

»API

The Key Management secrets engine has a full HTTP API. Please see the Key Management Secrets Engine API for more details.

github logoEdit this page
DocsAPILearnCommunityPrivacySecurityPress KitConsent Manager