Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

command/server: add dev-tls flag #16421

Merged
merged 16 commits into from Jul 22, 2022
Merged

command/server: add dev-tls flag #16421

merged 16 commits into from Jul 22, 2022

Conversation

jasonodonnell
Copy link
Contributor

@jasonodonnell jasonodonnell commented Jul 22, 2022

This adds new server subcommands, -dev-tls and -dev-tls-cert-dir, which will generate self-signed CA, server certificate, private key and will configure Vault to use them for TLS. This is helpful if you want to do dev work against a TLS enabled server. The generated certs are valid for 1 year.

During startup, the server will output the location of the CA so you can easily set the VAULT_CACERT environment variable:

[~/vault] vault server -dev-tls
==> Vault server configuration:
...
WARNING! dev mode is enabled! In this mode, Vault runs entirely in-memory
and starts unsealed with a single unseal key. The root token is already
authenticated to the CLI, so you can immediately begin using Vault.

You may need to set the following environment variable:

    $ export VAULT_ADDR='https://127.0.0.1:8200'
    $ export VAULT_CACERT='/var/folders/xh/8_phfcd132gfsx4gwbfcnwkm0000gq/T/vault-tls2597705420/vault-ca.pem'
...

Additionally you can specify -dev-tls-cert-dir to configure the directory where the TLS files are created. This will be helpful for guides and automated environments.

@jasonodonnell jasonodonnell added this to the 1.12.0-rc1 milestone Jul 22, 2022
command/server/config.go Outdated Show resolved Hide resolved
command/server/config.go Outdated Show resolved Hide resolved
command/server/config.go Outdated Show resolved Hide resolved
Copy link
Contributor

@cipherboy cipherboy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really should've batched these comments... :-/

But over all, I really like this and its something I've been wanting to do for a while (I added a tlsvault userscript instead which also has agent capabilities).

Other than the comments above, the one below is the only one I'd really suggest changing unless other people have strong comments. Looks good from a crypto perspective though. :-)

command/server/tls_util.go Outdated Show resolved Hide resolved
Copy link
Contributor

@cipherboy cipherboy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Three nits you can ignore if you want, but a reasonable suggestion to avoid duplicate code with the SDK (that'd fix another nit). :-)

command/server/tls_util.go Outdated Show resolved Hide resolved
command/server/tls_util.go Outdated Show resolved Hide resolved
command/server/tls_util.go Outdated Show resolved Hide resolved
command/server/tls_util.go Outdated Show resolved Hide resolved
Copy link
Contributor

@cipherboy cipherboy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New cert changes look perfect. :-)

Copy link
Contributor

@averche averche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few nit comments, feel free to ignore. Otherwise, the feature looks great and should be super helpful!

command/server.go Outdated Show resolved Hide resolved
command/server.go Outdated Show resolved Hide resolved
command/server.go Outdated Show resolved Hide resolved
command/server/config.go Outdated Show resolved Hide resolved
command/server/tls_util.go Outdated Show resolved Hide resolved
command/server/tls_util.go Show resolved Hide resolved
@jasonodonnell jasonodonnell enabled auto-merge (squash) July 22, 2022 17:30
Copy link
Contributor

@yhyakuna yhyakuna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only reviewed the docs file (server.mdx), but looks good to me. Super excited about this feature.

@jasonodonnell jasonodonnell merged commit 62cc652 into main Jul 22, 2022
@jasonodonnell jasonodonnell deleted the dev-tls branch July 22, 2022 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants