From ac316a2b9bbf1c5dec05d97e8f4c7c3b677c791e Mon Sep 17 00:00:00 2001 From: Matthias Gatto Date: Mon, 13 Nov 2023 17:55:47 +0100 Subject: [PATCH] add insecure option to test with self-signed TLS/SSL certificate Signed-off-by: Matthias Gatto --- outscale/config.go | 3 ++- outscale/provider.go | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/outscale/config.go b/outscale/config.go index 7676415a5..cee11c3d8 100644 --- a/outscale/config.go +++ b/outscale/config.go @@ -19,6 +19,7 @@ type Config struct { Endpoints map[string]interface{} X509cert string X509key string + Insecure bool } // OutscaleClient client @@ -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{ diff --git a/outscale/provider.go b/outscale/provider.go index 5443736ca..7ed82e53c 100644 --- a/outscale/provider.go +++ b/outscale/provider.go @@ -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{ @@ -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)