Skip to content

Commit

Permalink
Add option to disable tls verification when connecting to Xen api (xe…
Browse files Browse the repository at this point in the history
  • Loading branch information
chqr committed Jul 5, 2017
1 parent 950564b commit b9f611d
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions builder/xenserver/common/common_config.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package common

import (
"crypto/tls"
"errors"
"fmt"
"net/http"
"os"
"time"

Expand All @@ -16,10 +18,11 @@ import (
)

type CommonConfig struct {
Username string `mapstructure:"remote_username"`
Password string `mapstructure:"remote_password"`
HostIp string `mapstructure:"remote_host"`
ApiUrl string `mapstructure:"remote_url"`
Username string `mapstructure:"remote_username"`
Password string `mapstructure:"remote_password"`
HostIp string `mapstructure:"remote_host"`
ApiUrl string `mapstructure:"remote_url"`
ApiTlsSkipVerify bool `mapstructure:"remote_url_tls_skip_verify"`

VMName string `mapstructure:"vm_name"`
VMDescription string `mapstructure:"vm_description"`
Expand Down Expand Up @@ -254,7 +257,14 @@ func (config CommonConfig) GetSR(client xsclient.XenAPIClient) (*xsclient.SR, er
}

func (config CommonConfig) GetXenAPIClient() (*xsclient.XenAPIClient, error) {
rpc, err := xmlrpc.NewClient(config.ApiUrl, nil)
tlsConfig := tls.Config{}
if config.ApiTlsSkipVerify {
tlsConfig.InsecureSkipVerify = true
}
http_transport := http.Transport{
TLSClientConfig: &tlsConfig,
}
rpc, err := xmlrpc.NewClient(config.ApiUrl, &http_transport)

if err != nil {
return nil, err
Expand Down

0 comments on commit b9f611d

Please sign in to comment.