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

Add separate option for verifying incoming HTTPS traffic #2974

Merged
merged 3 commits into from
Apr 28, 2017

Conversation

kyhavlov
Copy link
Contributor

@kyhavlov kyhavlov commented Apr 27, 2017

Resolves #2969

@kyhavlov kyhavlov force-pushed the verify-incoming-https branch from 663f2fd to a301873 Compare April 28, 2017 00:03
@slackpad
Copy link
Contributor

slackpad commented Apr 28, 2017

To keep backward compatibility with the existing sense of verify_incoming I'm thinking we should add another RPC option and do logic like this:

actuallyVerifyIncomingHTTPS := verify_incoming || verify_incoming_https
actuallyVerifyIncomingRPC := verify_incoming || verify_incoming_rpc

This is still a little tricky, but I think it's simpler than some kind of "skip" flag for HTTPS. We can document that verify_incoming enables it for everything, otherwise you need to set them all individually.

Copy link
Contributor

@magiconair magiconair left a comment

Choose a reason for hiding this comment

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

The api/api_test.go could use a test that disabling the VerifyIncomingHTTPS allows a TLS connection without a matching certificate. This is a good case for the t.Run("...", func(t *testing.T) {...}) subtests since you can re-use the clients in the TestClientTLSOptions test.

CertFile string `json:"cert_file,omitempty"`
KeyFile string `json:"key_file,omitempty"`
VerifyIncoming bool `json:"verify_incoming,omitempty"`
VerifyIncomingHTTPS bool `json:"verify_incoming_https,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't you need a VerifyIncomingRPC as well here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, it should be here for completeness

* <a name="verify_incoming_rpc"></a><a href="#verify_incoming_rpc">`verify_incoming_rpc`</a> - If
set to true, Consul requires that all incoming RPC
connections make use of TLS and that the client provides a certificate signed
by the Certificate Authority from the [`ca_file`](#ca_file). By default, this is false, and
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't that need updating with the recent CAPath change you were working on?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, good catch


* <a name="verify_incoming_https"></a><a href="#verify_incoming_https">`verify_incoming_https`</a> - If
set to true, Consul requires that all incoming HTTPS
connections make use of TLS and that the client provides a certificate signed
by the Certificate Authority from the [`ca_file`](#ca_file). By default, this is false, and
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

api/api_test.go Outdated
if err != nil {
t.Fatal(err)
}
// Start a server without VerifyIncomingHTTPS
Copy link
Contributor

Choose a reason for hiding this comment

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

Move this to the top and give it a different name, e.g. srvNoVerify

api/api_test.go Outdated
@@ -256,6 +256,7 @@ func TestSetupTLSConfig(t *testing.T) {

func TestClientTLSOptions(t *testing.T) {
t.Parallel()
// Start a server that verifies incoming HTTPS connections
_, s := makeClientWithConfig(t, nil, func(conf *testutil.TestServerConfig) {
Copy link
Contributor

Choose a reason for hiding this comment

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

s/s/srvVerify/
Don't you have to set conf.VerifyIncomingHTTPS = true ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is set to true, right below this

@magiconair
Copy link
Contributor

LGTM

@magiconair
Copy link
Contributor

Please squash the change

@kyhavlov kyhavlov merged commit cd56a5e into master Apr 28, 2017
@kyhavlov kyhavlov deleted the verify-incoming-https branch April 28, 2017 23:16
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.

3 participants