Skip to content

Commit

Permalink
add insecure option to test with self-signed TLS/SSL certificate
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Gatto <[email protected]>
  • Loading branch information
outscale-mgo committed Nov 13, 2023
1 parent ddf53c7 commit ac316a2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion outscale/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Config struct {
Endpoints map[string]interface{}
X509cert string
X509key string
Insecure bool
}

// OutscaleClient client
Expand All @@ -28,7 +29,7 @@ type OutscaleClient struct {

// Client ...
func (c *Config) Client() (*OutscaleClient, error) {
tlsconfig := &tls.Config{InsecureSkipVerify: false}
tlsconfig := &tls.Config{InsecureSkipVerify: c.Insecure}
cert, err := tls.LoadX509KeyPair(c.X509cert, c.X509key)
if err == nil {
tlsconfig = &tls.Config{
Expand Down
7 changes: 7 additions & 0 deletions outscale/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ func Provider() terraform.ResourceProvider {
DefaultFunc: schema.EnvDefaultFunc("OUTSCALE_X509KEY", nil),
Description: "The path to your x509 key",
},
"insecure": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "tls insecure connection",
},
},

ResourcesMap: map[string]*schema.Resource{
Expand Down Expand Up @@ -193,6 +199,7 @@ func providerConfigureClient(d *schema.ResourceData) (interface{}, error) {
Endpoints: make(map[string]interface{}),
X509cert: d.Get("x509_cert_path").(string),
X509key: d.Get("x509_key_path").(string),
Insecure: d.Get("insecure").(bool),
}

endpointsSet := d.Get("endpoints").(*schema.Set)
Expand Down

0 comments on commit ac316a2

Please sign in to comment.