Skip to content

Commit b11e23f

Browse files
RachelTuckerrpmoore
authored andcommitted
GOSDK-30: Add a way to skip cert verification (#98)
1 parent e99fa99 commit b11e23f

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

ds3/ds3Client.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ func (clientBuilder *ClientBuilder) WithNetworkRetryCount(count int) *ClientBuil
6565
return clientBuilder
6666
}
6767

68+
func (clientBuilder *ClientBuilder) WithIgnoreServerCertificate(ignoreServerCert bool) *ClientBuilder {
69+
clientBuilder.connectionInfo.IgnoreServerCertificate = ignoreServerCert
70+
return clientBuilder
71+
}
72+
6873
func (clientBuilder *ClientBuilder) WithLogger(logger sdk_log.Logger) *ClientBuilder {
6974
clientBuilder.logger = logger
7075
return clientBuilder

ds3/networking/net.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
package networking
22

33
import (
4+
"crypto/tls"
45
"net/http"
56
"net/url"
67
"github.com/SpectraLogic/ds3_go_sdk/ds3/models"
78
)
89

910
type ConnectionInfo struct {
10-
Endpoint *url.URL
11-
Credentials *Credentials
12-
Proxy *url.URL
11+
Endpoint *url.URL
12+
Credentials *Credentials
13+
Proxy *url.URL
14+
IgnoreServerCertificate bool
1315
}
1416

1517
type Credentials struct {
@@ -27,9 +29,15 @@ type SendNetwork struct {
2729
}
2830

2931
func NewSendNetwork(connectionInfo *ConnectionInfo) Network {
30-
return &SendNetwork{
31-
transport: &http.Transport{Proxy: http.ProxyURL(connectionInfo.Proxy)},
32+
sendNetwork := &SendNetwork{
33+
transport: &http.Transport{
34+
Proxy: http.ProxyURL(connectionInfo.Proxy),
35+
},
3236
}
37+
if connectionInfo.IgnoreServerCertificate {
38+
sendNetwork.transport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
39+
}
40+
return sendNetwork
3341
}
3442

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

0 commit comments

Comments
 (0)