Skip to content

Commit

Permalink
GOSDK-30: Add a way to skip cert verification (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
RachelTucker authored and rpmoore committed Dec 6, 2019
1 parent e99fa99 commit b11e23f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
5 changes: 5 additions & 0 deletions ds3/ds3Client.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ func (clientBuilder *ClientBuilder) WithNetworkRetryCount(count int) *ClientBuil
return clientBuilder
}

func (clientBuilder *ClientBuilder) WithIgnoreServerCertificate(ignoreServerCert bool) *ClientBuilder {
clientBuilder.connectionInfo.IgnoreServerCertificate = ignoreServerCert
return clientBuilder
}

func (clientBuilder *ClientBuilder) WithLogger(logger sdk_log.Logger) *ClientBuilder {
clientBuilder.logger = logger
return clientBuilder
Expand Down
18 changes: 13 additions & 5 deletions ds3/networking/net.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package networking

import (
"crypto/tls"
"net/http"
"net/url"
"github.com/SpectraLogic/ds3_go_sdk/ds3/models"
)

type ConnectionInfo struct {
Endpoint *url.URL
Credentials *Credentials
Proxy *url.URL
Endpoint *url.URL
Credentials *Credentials
Proxy *url.URL
IgnoreServerCertificate bool
}

type Credentials struct {
Expand All @@ -27,9 +29,15 @@ type SendNetwork struct {
}

func NewSendNetwork(connectionInfo *ConnectionInfo) Network {
return &SendNetwork{
transport: &http.Transport{Proxy: http.ProxyURL(connectionInfo.Proxy)},
sendNetwork := &SendNetwork{
transport: &http.Transport{
Proxy: http.ProxyURL(connectionInfo.Proxy),
},
}
if connectionInfo.IgnoreServerCertificate {
sendNetwork.transport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
}
return sendNetwork
}

func (sendNetwork *SendNetwork) Invoke(httpRequest *http.Request) (models.WebResponse, error) {
Expand Down

0 comments on commit b11e23f

Please sign in to comment.