Skip to content
This repository was archived by the owner on Jun 21, 2022. It is now read-only.

Commit 11167a6

Browse files
author
US\paul.hoehne
committed
Adding ability to execute requests when there are defects in the cert.
1 parent 82e6967 commit 11167a6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

digest_auth_client.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package digest_auth_client
22

33
import (
44
"bytes"
5+
"crypto/tls"
56
"fmt"
67
"net/http"
78
"time"
@@ -16,6 +17,7 @@ type DigestRequest struct {
1617
Header http.Header
1718
Auth *authorization
1819
Wa *wwwAuthenticate
20+
CertVal bool
1921
}
2022

2123
type DigestTransport struct {
@@ -27,6 +29,7 @@ type DigestTransport struct {
2729
func NewRequest(username, password, method, uri, body string) DigestRequest {
2830
dr := DigestRequest{}
2931
dr.UpdateRequest(username, password, method, uri, body)
32+
dr.CertVal = true
3033
return dr
3134
}
3235

@@ -84,6 +87,14 @@ func (dr *DigestRequest) Execute() (resp *http.Response, err error) {
8487
client := &http.Client{
8588
Timeout: 30 * time.Second,
8689
}
90+
91+
if !dr.CertVal {
92+
tr := &http.Transport{
93+
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
94+
}
95+
client.Transport = tr
96+
}
97+
8798
if resp, err = client.Do(req); err != nil {
8899
return nil, err
89100
}
@@ -148,5 +159,12 @@ func (dr *DigestRequest) executeRequest(authString string) (resp *http.Response,
148159
Timeout: 30 * time.Second,
149160
}
150161

162+
if !dr.CertVal {
163+
tr := &http.Transport{
164+
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
165+
}
166+
client.Transport = tr
167+
}
168+
151169
return client.Do(req)
152170
}

0 commit comments

Comments
 (0)