-
Notifications
You must be signed in to change notification settings - Fork 113
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 insecure option as requested in GH-6 #31
Add insecure option as requested in GH-6 #31
Conversation
Note that this would close #4, too. |
Hi @natefaerber! Thanks for working on this. The functionality here looks good to me. The name feels a little off though, since "insecure" sounds to me like "disable TLS" rather than "skip certificate verification". What do you think about calling it |
@@ -37,6 +39,12 @@ func (c *Config) Client() (*consulapi.Client, error) { | |||
tlsConfig.CAFile = c.CAFile | |||
tlsConfig.CertFile = c.CertFile | |||
tlsConfig.KeyFile = c.KeyFile | |||
if c.InsecureHttps { | |||
if config.Scheme != "https" { | |||
return nil, fmt.Errorf("insecure_https is meant to be used when scheme is https") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error string if insecure_https is set but scheme is not https.
} | ||
} | ||
|
||
func TestResourceProvider_ConfigureTLSInsecureHttpsMismatch(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests that we error if insecure_https is used without https
Good idea, @apparentlymart. I have made these changes. Please review the strings to see if they make sense. $ make testacc TESTARGS='-run=TestResourceProvider'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test $(go list ./... |grep -v 'vendor') -v -run=TestResourceProvider -timeout 120m
? github.com/terraform-providers/terraform-provider-consul [no test files]
=== RUN TestResourceProvider
--- PASS: TestResourceProvider (0.00s)
=== RUN TestResourceProvider_impl
--- PASS: TestResourceProvider_impl (0.00s)
=== RUN TestResourceProvider_Configure
2018/01/06 11:03:58 [INFO] Initializing Consul client
2018/01/06 11:03:58 [INFO] Consul Client configured with address: 'demo.consul.io:80', scheme: 'https', datacenter: 'nyc3', insecure_https: 'false'
--- PASS: TestResourceProvider_Configure (0.00s)
=== RUN TestResourceProvider_ConfigureTLS
2018/01/06 11:03:58 [INFO] Initializing Consul client
2018/01/06 11:03:58 [INFO] Consul Client configured with address: 'demo.consul.io:80', scheme: 'https', datacenter: 'nyc3', insecure_https: 'false'
--- PASS: TestResourceProvider_ConfigureTLS (0.00s)
=== RUN TestResourceProvider_ConfigureTLSInsecureHttps
2018/01/06 11:03:58 [INFO] Initializing Consul client
2018/01/06 11:03:58 [INFO] Consul Client configured with address: 'demo.consul.io:80', scheme: 'https', datacenter: 'nyc3', insecure_https: 'true'
--- PASS: TestResourceProvider_ConfigureTLSInsecureHttps (0.00s)
=== RUN TestResourceProvider_ConfigureTLSInsecureHttpsMismatch
2018/01/06 11:03:58 [INFO] Initializing Consul client
--- PASS: TestResourceProvider_ConfigureTLSInsecureHttpsMismatch (0.00s)
PASS
ok github.com/terraform-providers/terraform-provider-consul/consul 0.030s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good and I've tested the connection on a local Consul dev container with TLS enabled on a self-signed cert. Good work! 👍
#6
This adds the insecure option. I used
insecure
instead ofssl_verify
because I saw the same option in OpenStack provider so thought it would be more acceptable. https://github.com/terraform-providers/terraform-provider-openstack/blob/master/openstack/config.go#L28I haven't been able to do a real world test against an insecure endpoint. I might be able to do that tomorrow.