Skip to content

Commit f682688

Browse files
committed
Added support of HTTPS Insecure connections (without ssl issuer validation).
1 parent d0ff330 commit f682688

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

go.mod

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
module github.com/pavel-z1/phpipam-sdk-go
2+
3+
require github.com/imdario/mergo v0.0.0-20160517064435-50d4dbd4eb0e
4+
5+
go 1.13

phpipam/phpipam.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ type Config struct {
4444

4545
// The user name for the PHPIPAM account.
4646
Username string
47+
48+
// Allow HTTPS connection without verification issuer
49+
Insecure bool
4750
}
4851

4952
// DefaultConfigProvider supplies a default configuration:

phpipam/request/request.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ package request
33

44
import (
55
"bytes"
6+
"crypto/tls"
67
"encoding/json"
78
"fmt"
89
"io/ioutil"
9-
"net/http"
1010
"log"
11+
"net/http"
1112

1213
"github.com/pavel-z1/phpipam-sdk-go/phpipam/session"
1314
)
@@ -131,7 +132,11 @@ func newRequestResponse(r *http.Response) *requestResponse {
131132
func (r *Request) Send() error {
132133
var req *http.Request
133134
var err error
135+
tr := &http.Transport{
136+
TLSClientConfig: &tls.Config{InsecureSkipVerify: r.Session.Config.Insecure},
137+
}
134138
client := &http.Client{
139+
Transport: tr,
135140
CheckRedirect: func(req *http.Request, via []*http.Request) error {
136141
return http.ErrUseLastResponse
137142
},

0 commit comments

Comments
 (0)