mirror of
				https://github.com/taigrr/wtf
				synced 2025-01-18 04:03:14 -08:00 
			
		
		
		
	add option to skip verification of jenkins server's certificate chain and hostname
This commit is contained in:
		
							parent
							
								
									4a1caf6e7c
								
							
						
					
					
						commit
						37b0d22dba
					
				@ -39,6 +39,7 @@ jenkins:
 | 
				
			|||||||
  refreshInterval: 300
 | 
					  refreshInterval: 300
 | 
				
			||||||
  url: "https://jenkins.domain.com/jenkins/view_url"
 | 
					  url: "https://jenkins.domain.com/jenkins/view_url"
 | 
				
			||||||
  user: "username"
 | 
					  user: "username"
 | 
				
			||||||
 | 
					  verifyServerCertificate: true
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Attributes
 | 
					### Attributes
 | 
				
			||||||
@ -61,3 +62,7 @@ Your Jenkins username. <br />
 | 
				
			|||||||
The url to your Jenkins project or view. <br />
 | 
					The url to your Jenkins project or view. <br />
 | 
				
			||||||
Values: A valid URI.
 | 
					Values: A valid URI.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					`verifyServerCertificate` <br />
 | 
				
			||||||
 | 
					_Optional_ <br />
 | 
				
			||||||
 | 
					Determines whether or not the server's certificate chain and host name are verified. <br />
 | 
				
			||||||
 | 
					Values: `true`, `false`.
 | 
				
			||||||
 | 
				
			|||||||
@ -163,7 +163,8 @@ width="320" height="68" alt="jenkins screenshot" /></p>
 | 
				
			|||||||
</span><span class="w">    </span>width<span class="p">:</span><span class="w"> </span><span class="m">3</span><span class="w">
 | 
					</span><span class="w">    </span>width<span class="p">:</span><span class="w"> </span><span class="m">3</span><span class="w">
 | 
				
			||||||
</span><span class="w">  </span>refreshInterval<span class="p">:</span><span class="w"> </span><span class="m">300</span><span class="w">
 | 
					</span><span class="w">  </span>refreshInterval<span class="p">:</span><span class="w"> </span><span class="m">300</span><span class="w">
 | 
				
			||||||
</span><span class="w">  </span>url<span class="p">:</span><span class="w"> </span><span class="s2">"https://jenkins.domain.com/jenkins/view_url"</span><span class="w">
 | 
					</span><span class="w">  </span>url<span class="p">:</span><span class="w"> </span><span class="s2">"https://jenkins.domain.com/jenkins/view_url"</span><span class="w">
 | 
				
			||||||
</span><span class="w">  </span>user<span class="p">:</span><span class="w"> </span><span class="s2">"username"</span></code></pre></div>
 | 
					</span><span class="w">  </span>user<span class="p">:</span><span class="w"> </span><span class="s2">"username"</span><span class="w">
 | 
				
			||||||
 | 
					</span><span class="w">  </span>verifyServerCertificate<span class="p">:</span><span class="w"> </span><span class="kc">true</span></code></pre></div>
 | 
				
			||||||
<h3 id="attributes">Attributes</h3>
 | 
					<h3 id="attributes">Attributes</h3>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<p><code>enabled</code> <br />
 | 
					<p><code>enabled</code> <br />
 | 
				
			||||||
@ -184,6 +185,11 @@ Your Jenkins username. <br /></p>
 | 
				
			|||||||
The url to your Jenkins project or view. <br />
 | 
					The url to your Jenkins project or view. <br />
 | 
				
			||||||
Values: A valid URI.</p>
 | 
					Values: A valid URI.</p>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<p><code>verifyServerCertificate</code> <br />
 | 
				
			||||||
 | 
					<em>Optional</em> <br />
 | 
				
			||||||
 | 
					Determines whether or not the server’s certificate chain and host name are verified. <br />
 | 
				
			||||||
 | 
					Values: <code>true</code>, <code>false</code>.</p>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            <div class="footer">
 | 
					            <div class="footer">
 | 
				
			||||||
 | 
				
			|||||||
@ -2,12 +2,15 @@ package jenkins
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"bytes"
 | 
						"bytes"
 | 
				
			||||||
 | 
						"crypto/tls"
 | 
				
			||||||
	"encoding/json"
 | 
						"encoding/json"
 | 
				
			||||||
	"io"
 | 
						"io"
 | 
				
			||||||
	"io/ioutil"
 | 
						"io/ioutil"
 | 
				
			||||||
	"net/http"
 | 
						"net/http"
 | 
				
			||||||
	"net/url"
 | 
						"net/url"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"github.com/senorprogrammer/wtf/wtf"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func Create(jenkinsURL string, username string, apiKey string) (*View, error) {
 | 
					func Create(jenkinsURL string, username string, apiKey string) (*View, error) {
 | 
				
			||||||
@ -26,7 +29,13 @@ func Create(jenkinsURL string, username string, apiKey string) (*View, error) {
 | 
				
			|||||||
	req, _ := http.NewRequest("GET", jenkinsAPIURL.String(), nil)
 | 
						req, _ := http.NewRequest("GET", jenkinsAPIURL.String(), nil)
 | 
				
			||||||
	req.SetBasicAuth(username, apiKey)
 | 
						req.SetBasicAuth(username, apiKey)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	httpClient := &http.Client{}
 | 
						verifyServerCertificate := wtf.Config.UBool("wtf.mods.jenkins.verifyServerCertificate", true)
 | 
				
			||||||
 | 
						httpClient := &http.Client{Transport: &http.Transport{
 | 
				
			||||||
 | 
							TLSClientConfig: &tls.Config{
 | 
				
			||||||
 | 
								InsecureSkipVerify: !verifyServerCertificate,
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	resp, err := httpClient.Do(req)
 | 
						resp, err := httpClient.Do(req)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user