Skip to content

Commit 3a08cc9

Browse files
furukawataka02phinze
authored andcommitted
provider/vsphere: Add allow_unverified_ssl flag for unverified SSL requests
1 parent 2a49ebb commit 3a08cc9

3 files changed

Lines changed: 15 additions & 5 deletions

File tree

builtin/providers/vsphere/config.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,11 @@ import (
99
"golang.org/x/net/context"
1010
)
1111

12-
const (
13-
defaultInsecureFlag = true
14-
)
15-
1612
type Config struct {
1713
User string
1814
Password string
1915
VSphereServer string
16+
InsecureFlag bool
2017
}
2118

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

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

31-
client, err := govmomi.NewClient(context.TODO(), u, defaultInsecureFlag)
28+
client, err := govmomi.NewClient(context.TODO(), u, c.InsecureFlag)
3229
if err != nil {
3330
return nil, fmt.Errorf("Error setting up client: %s", err)
3431
}

builtin/providers/vsphere/provider.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ func Provider() terraform.ResourceProvider {
2929
DefaultFunc: schema.EnvDefaultFunc("VSPHERE_SERVER", nil),
3030
Description: "The vSphere Server name for vSphere API operations.",
3131
},
32+
33+
"allow_unverified_ssl": &schema.Schema{
34+
Type: schema.TypeBool,
35+
Optional: true,
36+
DefaultFunc: schema.EnvDefaultFunc("VSPHERE_ALLOW_UNVERIFIED_SSL", false),
37+
Description: "If set, VMware vSphere client will permit unverifiable SSL certificates.",
38+
},
3239
},
3340

3441
ResourcesMap: map[string]*schema.Resource{
@@ -44,6 +51,7 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
4451
User: d.Get("user").(string),
4552
Password: d.Get("password").(string),
4653
VSphereServer: d.Get("vsphere_server").(string),
54+
InsecureFlag: d.Get("allow_unverified_ssl").(bool),
4755
}
4856

4957
return config.Client()

website/source/docs/providers/vsphere/index.html.markdown

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ The following arguments are used to configure the VMware vSphere Provider:
5858
* `vsphere_server` - (Required) This is the vCenter server name for vSphere API
5959
operations. Can also be specified with the `VSPHERE_SERVER` environment
6060
variable.
61+
* `allow_unverified_ssl` - (Optional) Boolean that can be set to true to
62+
disable SSL certificate verification. This should be used with care as it
63+
could allow an attacker to intercept your auth token. If omitted, default
64+
value is `false`. Can also be specified with the `VSPHERE_ALLOW_UNVERIFIED_SSL`
65+
environment variable.
6166

6267
## Acceptance Tests
6368

0 commit comments

Comments
 (0)