This repository has been archived on 2026-11-19. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
vault-plugin-secrets-gpg/README.md
T
unkin-agent 873069c6bd
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
Add MIT license, rewrite README and add path reference docs
2026-11-16 23:12:28 +11:00

3.3 KiB

vault-plugin-secrets-gpg

A secrets engine for HashiCorp Vault and OpenBao that manages OpenPGP (GPG) keys and signs, verifies, encrypts and decrypts with them. Think of it as the transit engine, but the keys are OpenPGP keys.

Why use this plugin?

Private keys are generated and stored in Vault's barrier storage. They never leave Vault unless you mark a key exportable. The engine hands out a standard armored public key, so gpg, pass and other OpenPGP tools can encrypt to the key. Decryption goes back through Vault. Keys are versioned: when you rotate a key, older versions stay available, so old signatures still verify and old ciphertext still decrypts.

To manage the engine's mounts and keys from Terraform or OpenTofu, use terraform-provider-gpgvaultsecret.

Requirements

  • HashiCorp Vault 1.12+ or OpenBao 2.x. The same binary works on both.
  • Go 1.25+ (only if you build from source)

Installation

Download a binary from the releases page, or build one:

make build   # -> dist/vault-plugin-secrets-gpg

Copy the binary into the server's plugin_directory, then register it in the plugin catalog and enable the engine. On OpenBao, run the same commands with bao in place of vault.

SHA256=$(sha256sum /etc/vault/plugins/vault-plugin-secrets-gpg | cut -d' ' -f1)
vault plugin register -sha256="$SHA256" secret vault-plugin-secrets-gpg
vault secrets enable -path=gpg vault-plugin-secrets-gpg

Usage

The engine has no mount-level configuration. Each key holds its own settings (see keys).

All binary input and output is base64-encoded.

# create a key (repeating the write returns the existing key)
vault write gpg/keys/app algorithm=rsa-4096 identity="App <app@example.com>"
vault read gpg/keys/app

# sign / verify
sig=$(vault write -field=signature gpg/sign/app input=$(base64 <<<"ship it"))
vault write -field=valid gpg/verify/app input=$(base64 <<<"ship it") signature="$sig"

# encrypt / decrypt
ct=$(vault write -field=ciphertext gpg/encrypt/app plaintext=$(base64 <<<"secret"))
vault write -field=plaintext gpg/decrypt/app ciphertext="$ct" | base64 -d

# rotate; ciphertext from older versions still decrypts
vault write gpg/keys/app/rotate

With pass

pass needs only the public key to encrypt. Decryption goes through Vault.

vault read -field=public_key gpg/keys/app | gpg --import
pass init "$(vault read -field=fingerprint gpg/keys/app)"
pass insert email/example

vault write -field=plaintext gpg/decrypt/app \
  ciphertext=$(base64 -w0 ~/.password-store/email/example.gpg) | base64 -d

Documentation

Full path reference:

Development

make test   # unit tests, including gpg/pass interop when those binaries exist
make lint
make e2e    # full lifecycle against Vault and OpenBao in Docker

License

MIT