Package: vault-certificate-deploy
vault-cert-deployDeploy SSL certificates from HashiCorp's Vault secret server
Script is able to deploy certificates from KV store of Vault
or when you use issue version of script it use PKI secret storage.As auth method is usedApprole, you need role and secret id
deployed to server from different systems/locations. More
about this in usecase section.On the first look, it may be little bit strange combination of
config file and cli options. You can combine them in different
ways to support various types of deployments to meet the basic
security concepts.Why do I need Vault Server ?We are using Let's Encrypt for almost all of our SSL/TLS certificates.
We also have complex infrastructure so we have to retrieve
certificates in central place and then we distribute them into
datacenters, clouds or any other applications.How deploy work ?It deploy certificates to specified directory and create
two directoriescertsandprivate.certs has mode 0644private keys has mode 0640it deploys all secret content from vault, keys as files with suitable extension .InstallationPython PyPIpip install vault-certificate-deployManualManual installationgit clone https://github.com/rvojcik/vault-certificate-deploy
cd vault-certificate-deploy
sudo python ./setup.py installIn the endvault-cert-deploy --helpExample configurationCan be found inconfig.example.Role and Secret id can be passed from script arguments.
You could combine-nand--cert-listparameters.Invaultsection of configuration it is possible to
setmount_pointof secret in Vault.
By default it iscert.
You could also change this option in argumentsVault ConfigurationScript usesApproleauth.First enable AppRole auth if it's notvault auth enable approleYou have to create your policy first.
Use Vaultdocumentationaround policies and then continue here.Example policy with basic medium security can be# Cert Deploy Policy
# Give ability to
# - read all certificates
# - don't permit list certificates
#
path "/certs/*" {
  capabilities = ["read"]
}Configure your rolevault write auth/approle/role/my-role \
secret_id_ttl=0 \
token_num_uses=0 \
token_ttl=20m \
token_max_ttl=30m \
policies="my-policy,default"Retrieve your approle IDvault read auth/approle/role/my-role/role-idGet secret ID (onetime operation)vault write -f auth/approle/role/my-role/secret-idUse CasesIt is important to don't have role-id and secret-id together
in one repository or configuration management.PuppetI deploy my servers with installer which create file/etc/vault_role_idwhich containrole-idof the approle.Then I have Puppet Configuration management which deploy this system with
all files andsecret-idin configuration file (/etc/vault-deploy/config.conf).Puppet create also file with certs/secret names/etc/ssl-deploy-certs.confthen you can run deploy like this:vault-certificate-deploy.py -c /etc/vault-deploy/config.conf \
  --cert-list /etc/ssl-deploy-certs.conf \
  --role-id $(cat /etc/vault_role_id)HooksScripts support definition of hooks directory (hook_dir) where you can plase any exacutable file. Every file in hooks directory is executed every time ssl certificates are deployed or changed. You could script any action you need.Why  ?I store Puppet configuration in Git, and therefore I have not
role-id and secret-id together in my repository.
I choose to deploysecret-idwith puppet because when need to
rotate secret-id it is automaticly deployed by puppet to infrastructure.What is issue version of the script ?Issue version of the command or script uses different Secret Storage
Engine. It usesPKIwhich gives you ability to create
your own CA or Intermediate CA. Vault handle both certs generation and issuing.You have to specify PKI mount point with--vault-pkioption.
This pki mount_point is used as subdirectory of storage path in your
config file. In this subdirectory we create same structurecertsandprivatelike in other version of the script.What is difference in function ?Issue command check if certificates you define exists, and it check their expiration time
defined by--cert-min-ttloption.It basicaly means it generates and issue certificates for you, if they not exist, or if they are
close to expire. It is great automation capability in combination with Configuration
Management systems. You don't have to take care of the certificates anymore.If certificates you define exists and are valid script just do nothing.ExamplesCreate certificate server1.domin.intra on PKI mounted in pki mount point of vault.
If you want to issue new certificate, you have to issue it against some role. In
our case this role istest.More information aboutPKI roles in documentation.vault-certificate-issue-deploy --vault-pki pki -n server1.domain.intra --cert-role testIf we need some subject alternative name you can define it as--cert-extra-optionsvault-certificate-issue-deploy --vault-pki pki -n server1.domain.intra --cert-role test --cert-extra-options "alt_names=console.domain.intra,console1.domain.intra,admin.domain.intra"Result of this can be something like thisX509v3 Subject Alternative Name: 
     DNS:console.domain.intra, DNS:console1.domain.intra, DNS:admin.domain.intraSecurity Best PracticesNever store your role-id and secret-id in your repository togetherDeploy secret-id in way it's quick and easy for you to rotate/changeIn production always useverify_tls=yeswhen deploy secret-id and role-id in files/config, always set correct permissions (eg.0400,0600)in vault set policy to your approle only forreadcapability, it's enoughfor highest security set individual approle for every server and set individual policy for every server and certificate