From 5f2024034069906a9ba8606b171931be803c1944 Mon Sep 17 00:00:00 2001 From: Ash Wilson Date: Thu, 19 Feb 2015 11:15:24 -0500 Subject: [PATCH] Use --openstack-insecure to disable TLS checking. At your own risk! Signed-off-by: Ash Wilson --- drivers/openstack/client.go | 12 ++++++++++++ drivers/openstack/openstack.go | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/drivers/openstack/client.go b/drivers/openstack/client.go index 5051e8ad86..fd2392c435 100644 --- a/drivers/openstack/client.go +++ b/drivers/openstack/client.go @@ -1,6 +1,9 @@ package openstack import ( + "crypto/tls" + "net/http" + log "github.com/Sirupsen/logrus" "github.com/rackspace/gophercloud" "github.com/rackspace/gophercloud/openstack" @@ -393,6 +396,7 @@ func (c *GenericClient) Authenticate(d *Driver) error { log.WithFields(log.Fields{ "AuthUrl": d.AuthUrl, + "Insecure": d.Insecure, "Username": d.Username, "TenantName": d.TenantName, "TenantID": d.TenantId, @@ -411,6 +415,14 @@ func (c *GenericClient) Authenticate(d *Driver) error { if err != nil { return err } + + if d.Insecure { + // Configure custom TLS settings. + config := &tls.Config{InsecureSkipVerify: true} + transport := &http.Transport{TLSClientConfig: config} + provider.HTTPClient.Transport = transport + } + c.Provider = provider return nil diff --git a/drivers/openstack/openstack.go b/drivers/openstack/openstack.go index b0969b60c6..6dbbdd0cf9 100644 --- a/drivers/openstack/openstack.go +++ b/drivers/openstack/openstack.go @@ -22,6 +22,7 @@ const ( type Driver struct { AuthUrl string + Insecure bool Username string Password string TenantName string @@ -54,6 +55,7 @@ type Driver struct { type CreateFlags struct { AuthUrl *string + Insecure *bool Username *string Password *string TenantName *string @@ -87,6 +89,10 @@ func GetCreateFlags() []cli.Flag { Usage: "OpenStack authentication URL", Value: "", }, + cli.BoolFlag{ + Name: "openstack-insecure", + Usage: "Disable TLS credential checking.", + }, cli.StringFlag{ EnvVar: "OS_USERNAME", Name: "openstack-username", @@ -203,6 +209,7 @@ func (d *Driver) DriverName() string { func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error { d.AuthUrl = flags.String("openstack-auth-url") + d.Insecure = flags.Bool("openstack-insecure") d.Username = flags.String("openstack-username") d.Password = flags.String("openstack-password") d.TenantName = flags.String("openstack-tenant-name")