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

auto_encrypt and verify_incoming #6811

Merged
merged 3 commits into from
Nov 27, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion agent/config/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,7 @@ func (b *Builder) Validate(rt RuntimeConfig) error {

if rt.AutoEncryptAllowTLS {
if !rt.VerifyIncoming && !rt.VerifyIncomingRPC {
return fmt.Errorf("if auto_encrypt.allow_tls is turned on, either verify_incoming or verify_incoming_rpc must be enabled.")
b.warn("if auto_encrypt.allow_tls is turned on, either verify_incoming or verify_incoming_rpc should be enabled. It is necessary to turn it off during a migration to TLS, but it should definitely be turned on afterwards.")
}
}

Expand Down
9 changes: 7 additions & 2 deletions agent/config/runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2684,7 +2684,7 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
},
},
{
desc: "auto_encrypt.allow fails without verify_incoming or verify_incoming_rpc",
desc: "auto_encrypt.allow warns without verify_incoming or verify_incoming_rpc",
args: []string{
`-data-dir=` + dataDir,
},
Expand All @@ -2694,7 +2694,12 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
hcl: []string{`
auto_encrypt { allow_tls = true }
`},
err: "if auto_encrypt.allow_tls is turned on, either verify_incoming or verify_incoming_rpc must be enabled.",
warns: []string{"if auto_encrypt.allow_tls is turned on, either verify_incoming or verify_incoming_rpc should be enabled. It is necessary to turn it off during a migration to TLS, but it should definitely be turned on afterwards."},
patch: func(rt *RuntimeConfig) {
rt.DataDir = dataDir
rt.AutoEncryptAllowTLS = true
rt.ConnectEnabled = true
},
},
{
desc: "test connect vault provider configuration",
Expand Down
13 changes: 11 additions & 2 deletions tlsutil/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,11 +323,20 @@ func (c *Configurator) check(config Config, pool *x509.CertPool, cert *tls.Certi

// Ensure we have a CA and cert if VerifyIncoming is set
if config.anyVerifyIncoming() {
autoEncryptMsg := " AutoEncrypt only secures the connection between client and server and doesn't affect incoming connections on the client."
if pool == nil {
return fmt.Errorf("VerifyIncoming set, and no CA certificate provided!")
errMsg := "VerifyIncoming set, and no CA certificate provided!"
if config.AutoEncryptTLS {
errMsg += autoEncryptMsg
Copy link
Member

Choose a reason for hiding this comment

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

Nice!

}
return fmt.Errorf(errMsg)
}
if cert == nil {
return fmt.Errorf("VerifyIncoming set, and no Cert/Key pair provided!")
errMsg := "VerifyIncoming set, and no Cert/Key pair provided!"
if config.AutoEncryptTLS {
errMsg += autoEncryptMsg
}
return fmt.Errorf(errMsg)
}
}
return nil
Expand Down