Giter VIP home page Giter VIP logo

vaultsign's Introduction

vaultsign https://github.com/martinbaillie/vaultsign/workflows/tests/badge.svg

About

vaultsign is a small CLI that can be used to sign (and verify) git commits and tags using HashiCorp’s Vault.

It works both with the out-of-the-box transit backend and LeSuisse’s GPG plugin.

NOTE: You will want the latter for those GitHub ✔️ verified feels.

How?

vaultsign implements just enough of the GPG CLI interface and status protocol to proxy the git originating sign and verify requests onwards to your specified Vault backend endpoint.

Why?

Vault’s signature related backends are useful for realising code provenance in regulated and other high security environments.

You might, for example, build and sign software binaries using CI and Vault infrastructure you control, then store them in an artefact repository (such as GitHub’s Releases), and later verify those binaries again with Vault during deployment to cryptographically prove they were built on your terms without tampering.

This works well for deployable artefacts like binaries but gets a little more awkward when some of related deployment collateral is say, IaC files (such as Terraform) living on a VCS branch or tag.

One option here is to tarball up this deployment collateral and sign/store/verify that.

Another is to make use of vaultsign.

With it, the CI process can sign a git commit or, more commonly, a release tag at the same time as it signs the just-cut binaries. Subsequently, they can all be verified together during a deployment.

Doing all of this in your CI/CD infrastructure with Vault removes much of the need to deal with individual employee GPG keys or X.509 certificates (for S/Mime) to achieve code provenance at the VCS level.

Usage

There is a built-in help that you may find useful:

vaultsign --help
vaultsign 1.0.0
Martin Baillie <[email protected]>
Sign/verify git commits using HashiCorp Vault.

USAGE:
    vaultsign [FLAGS] [OPTIONS] <--sign|--verify> [FILE]...

FLAGS:
    -a, --armor          Create ASCII armored output
    -b, --detach-sign    Make a detached signature
    -h, --help           Prints help information
    -s, --sign           Make a signature
    -V, --version        Prints version information
    -v, --verify         Verify a signature

OPTIONS:
        --keyid-format <keyid_format>           Select how to display key IDs [possible values: long]
    -u, --local-user <local_user>               USER-ID to sign or decrypt
        --status-fd <status_fd>                 Write special status strings to the file descriptor n. [possible values:
                                                1, 2]
        --vault_addr <vault_addr>               Vault address to use for sign and verify actions [env: VAULT_ADDR]
                                                [default: http://127.0.0.1:8200]
        --vault_sign_path <vault_sig_path>      The Vault path to use for sign actions [env: VAULT_SIGN_PATH]  [default:
                                                transit/sign/test/sha2-256]
        --vault_verify_path <vault_ver_path>    The Vault path to use for verify actions [env: VAULT_VERIFY_PATH]
                                                [default: transit/verify/test]

ARGS:
    <FILE>...

NOTE:
    The vaultsign CLI implements just enough of the full GPG CLI interface
    for happy-path git sign and verify operations to function correctly.

Mostly, though, you just need to tell your git CLI to use vaultsign:

git config --local gpg.program /path/to/vaultsign

And set some Vault related environment variables:

# The location of your Vault. Mandatory always.
export VAULT_ADDR=https://vault.your.corp:8200

# The signing backend endpoint (transit or gpg) and optionally hashing function
# to use. Mandatory for signing.
export VAULT_SIGN_PATH=transit/sign/test/sha2-256
export VAULT_SIGN_PATH=gpg/sign/test/sha2-256

# The verify backend endpoint (transit or gpg). Mandatory for verifying.
export VAULT_VERIFY_PATH=transit/verify/test
export VAULT_VERIFY_PATH=gpg/verify/test

# The SNI to present during the TLS handshake (if different from the Vault HTTP
# host name). Useful when your Vault is exposed through an AWS private link for
# example. Optional.
export VAULT_TLS_SERVER_NAME=hostname.to.use.for.sni.com

NOTE: vaultsign will discover an existing Vault token from either the environment or the home directory using HashiCorp’s established naming (VAULT_TOKEN) and path (~/.vault-token). The environment takes precedence here.

Example

# Login to your vault.
export VAULT_ADDR=http://127.0.0.1:8200
vault login

# Tell git to use vaultsign.
git config --local gpg.program /path/to/vaultsign

# Sign a commit and tag.
export VAULT_SIGN_PATH=transit/sign/test/sha2-256
git commit -m "test signed commit" -S
git tag -m "test signed tag" -s test

# Verify the same commit and tag.
export VAULT_VERIFY_PATH=transit/verify/test
git verify-commit HEAD
git log -1 --show-signature
git verify-tag test

Install

You can either download a signed static binary release or compile from source for your target architecture.

Download

Always download and verify the latest stable release from the GitHub releases section.

Verify

# Import my key.
curl -sS https://github.com/martinbaillie.gpg | gpg --import -

# Verify the authenticity.
gpg --verify SHA256SUMS.sig SHA256SUMS

# Verify the integrity.
shasum -a 256 -c SHA256SUMS

Build

If you are a Nix user then you can take advantage of the shell.nix to provide a functional development environment for compilation and tests.

nix-shell --pure --run "make release"

Otherwise, any sufficiently modern Rust toolchain should be able to compile vaultsign.

NOTE: regarding OpenSSL.

If you are compiling from source, vaultsign links against your system’s native OpenSSL distribution. Ensure you have the dependencies listed in shell.nix.

If you are using the pre-compiled Darwin version from the releases section then it is not static so ensure you have OpenSSL version 1.1 installed.

GitHub Verification

If you want that coveted GitHub green verified tick for your Vault-signed commits and tags then you must use LeSuisse’s GPG plugin in Vault. GitHub does not know how to verify Vault transit backend signatures.

With that done, you just have to ensure the GPG key email and VCS author email match, i.e.:

  • GPG Private key generated/imported in Vault has a real name and email (see here).
  • GPG Public key is added to the GitHub user doing the VCS operation, with those same details.

vaultsign's People

Contributors

dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

vaultsign's Issues

error: Problem with arguments

9b5c2799e9b1:/validate-sudoers # env | grep VAULT
VAULT_TOKEN=<very secret token>
VAULT_SIGN_PATH=.../sha2-512
VAULT_VERIFY_PATH=../folder
VAULT_ADDR=https://vaultserver:8200
9b5c2799e9b1:/validate-sudoers # /root/bin/vaultsign --armor --detach-sign --sign --keyid-format long --local-user root --status-fd 1 README.md

error: The following required arguments were not provided:
--verify

9b5c2799e9b1:/validate-sudoers # /root/bin/vaultsign --armor --detach-sign --sign --verify --keyid-format long --local-user root --status-fd 1 README.md

error: The argument '--verify' cannot be used with one or more of the other specified arguments

9b5c2799e9b1:/validate-sudoers # /root/bin/vaultsign --armor --detach-sign --verify --keyid-format long --local-user root --status-fd 1 README.md

error: The following required arguments were not provided:
--sign

Container: SLES15SP5
Vault v1.16.2 (c6e4c2d4dc3b0d57791881b087c026e2f75a87cb), built 2024-04-22T16:25:54Z
vaultsign 1.0.0

error: The following required arguments were not provided: --verify

Hi

On exporting the needed variables to a working gpg LeSuisse Hashicorp Vault implementation,

export VAULT_TOKEN
export VAULT_ADDR
export VAULT_SIGN_PATH
export VAULT_VERIFY_PATH

/root/bin/vaultsign --armor --detach-sign --keyid-format long --local-user root --sign set_vs.sh

We get:

error: The following required arguments were not provided:
    --verify

Then if you specify --verify, it tell you to add required --sign

Our server
Sles15 SP5

It is in test for GitHup gpg signing commits.

Please help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.