Skip to content

Commit 37b0d22

Browse files
committed
add option to skip verification of jenkins server's certificate chain and hostname
1 parent 4a1caf6 commit 37b0d22

3 files changed

Lines changed: 22 additions & 2 deletions

File tree

‎_site/content/posts/modules/jenkins.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ jenkins:
3939
refreshInterval: 300
4040
url: "https://jenkins.domain.com/jenkins/view_url"
4141
user: "username"
42+
verifyServerCertificate: true
4243
```
4344
4445
### Attributes
@@ -61,3 +62,7 @@ Your Jenkins username. <br />
6162
The url to your Jenkins project or view. <br />
6263
Values: A valid URI.
6364

65+
`verifyServerCertificate` <br />
66+
_Optional_ <br />
67+
Determines whether or not the server's certificate chain and host name are verified. <br />
68+
Values: `true`, `false`.

‎docs/posts/modules/jenkins/index.html‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ <h2 id="configuration">Configuration</h2>
163163
</span><span class="w"> </span>width<span class="p">:</span><span class="w"> </span><span class="m">3</span><span class="w">
164164
</span><span class="w"> </span>refreshInterval<span class="p">:</span><span class="w"> </span><span class="m">300</span><span class="w">
165165
</span><span class="w"> </span>url<span class="p">:</span><span class="w"> </span><span class="s2">&#34;https://jenkins.domain.com/jenkins/view_url&#34;</span><span class="w">
166-
</span><span class="w"> </span>user<span class="p">:</span><span class="w"> </span><span class="s2">&#34;username&#34;</span></code></pre></div>
166+
</span><span class="w"> </span>user<span class="p">:</span><span class="w"> </span><span class="s2">&#34;username&#34;</span><span class="w">
167+
</span><span class="w"> </span>verifyServerCertificate<span class="p">:</span><span class="w"> </span><span class="kc">true</span></code></pre></div>
167168
<h3 id="attributes">Attributes</h3>
168169

169170
<p><code>enabled</code> <br />
@@ -184,6 +185,11 @@ <h3 id="attributes">Attributes</h3>
184185
The url to your Jenkins project or view. <br />
185186
Values: A valid URI.</p>
186187

188+
<p><code>verifyServerCertificate</code> <br />
189+
<em>Optional</em> <br />
190+
Determines whether or not the server&rsquo;s certificate chain and host name are verified. <br />
191+
Values: <code>true</code>, <code>false</code>.</p>
192+
187193
</div>
188194

189195
<div class="footer">

‎jenkins/client.go‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@ package jenkins
22

33
import (
44
"bytes"
5+
"crypto/tls"
56
"encoding/json"
67
"io"
78
"io/ioutil"
89
"net/http"
910
"net/url"
1011
"strings"
12+
13+
"github.com/senorprogrammer/wtf/wtf"
1114
)
1215

1316
func Create(jenkinsURL string, username string, apiKey string) (*View, error) {
@@ -26,7 +29,13 @@ func Create(jenkinsURL string, username string, apiKey string) (*View, error) {
2629
req, _ := http.NewRequest("GET", jenkinsAPIURL.String(), nil)
2730
req.SetBasicAuth(username, apiKey)
2831

29-
httpClient := &http.Client{}
32+
verifyServerCertificate := wtf.Config.UBool("wtf.mods.jenkins.verifyServerCertificate", true)
33+
httpClient := &http.Client{Transport: &http.Transport{
34+
TLSClientConfig: &tls.Config{
35+
InsecureSkipVerify: !verifyServerCertificate,
36+
},
37+
},
38+
}
3039
resp, err := httpClient.Do(req)
3140

3241
if err != nil {

0 commit comments

Comments
 (0)
⌂ 换网址