Skip to content
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

provider/vsphere: Add insecure option for 'insecure' SSL requests #3933

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions builtin/providers/vsphere/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@ import (
"golang.org/x/net/context"
)

const (
defaultInsecureFlag = true
)

type Config struct {
User string
Password string
VCenterServer string
InsecureFlag bool
}

// Client() returns a new client for accessing VMWare vSphere.
Expand All @@ -28,7 +25,7 @@ func (c *Config) Client() (*govmomi.Client, error) {

u.User = url.UserPassword(c.User, c.Password)

client, err := govmomi.NewClient(context.TODO(), u, defaultInsecureFlag)
client, err := govmomi.NewClient(context.TODO(), u, c.InsecureFlag)
if err != nil {
return nil, fmt.Errorf("Error setting up client: %s", err)
}
Expand Down
14 changes: 11 additions & 3 deletions builtin/providers/vsphere/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,28 @@ func Provider() terraform.ResourceProvider {
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("VSPHERE_USER", nil),
Description: "The user name for vSphere API operations.",
Description: "The user name for VMware vSphere API operations.",
},

"password": &schema.Schema{
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("VSPHERE_PASSWORD", nil),
Description: "The user password for vSphere API operations.",
Description: "The user password for VMware vSphere API operations.",
},

"vcenter_server": &schema.Schema{
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("VSPHERE_VCENTER", nil),
Description: "The vCenter Server name for vSphere API operations.",
Description: "The VMware vCenter Server name for VMware vSphere API operations.",
},

"allow_unverified_ssl": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("VSPHERE_ALLOW_UNVERIFIED_SSL", false),
Description: "If set, VMware vSphere client will permit unverifiable SSL certificates.",
},
},

Expand All @@ -44,6 +51,7 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
User: d.Get("user").(string),
Password: d.Get("password").(string),
VCenterServer: d.Get("vcenter_server").(string),
InsecureFlag: d.Get("allow_unverified_ssl").(bool),
}

return config.Client()
Expand Down
5 changes: 5 additions & 0 deletions website/source/docs/providers/vsphere/index.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ The following arguments are used to configure the VMware vSphere Provider:
* `vcenter_server` - (Required) This is the vCenter server name for vSphere API
operations. Can also be specified with the `VSPHERE_VCENTER` environment
variable.
* `allow_unverified_ssl` - (Optional) Boolean that can be set to true to
disable SSL certificate verification. This should be used with care as it
could allow an attacker to intercept your auth token. If omitted, default
value is `false`. Can also be specified with the `VSPHERE_ALLOW_UNVERIFIED_SSL`
environment variable.

## Acceptance Tests

Expand Down