Use --openstack-insecure to disable TLS checking.

At your own risk!

Signed-off-by: Ash Wilson <ash.wilson@rackspace.com>
This commit is contained in:
Ash Wilson 2015-02-19 11:15:24 -05:00
parent a914a39167
commit bd2bdda827
2 changed files with 19 additions and 0 deletions

View File

@ -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

View File

@ -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")