mirror of
https://github.com/Threnklyn/jira.git
synced 2026-06-03 19:48:28 +02:00
Add insecure option for TLS endpoints
This gives the option of disabling TLS certificate verification for the server. Closes #25
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"net/http/cookiejar"
|
"net/http/cookiejar"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"crypto/tls"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"runtime"
|
"runtime"
|
||||||
@@ -36,15 +37,26 @@ func New(opts map[string]interface{}) *Cli {
|
|||||||
endpoint, _ := opts["endpoint"].(string)
|
endpoint, _ := opts["endpoint"].(string)
|
||||||
url, _ := url.Parse(strings.TrimRight(endpoint, "/"))
|
url, _ := url.Parse(strings.TrimRight(endpoint, "/"))
|
||||||
|
|
||||||
|
transport := &http.Transport{
|
||||||
|
TLSClientConfig: &tls.Config{},
|
||||||
|
}
|
||||||
|
|
||||||
if project, ok := opts["project"].(string); ok {
|
if project, ok := opts["project"].(string); ok {
|
||||||
opts["project"] = strings.ToUpper(project)
|
opts["project"] = strings.ToUpper(project)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if insecureSkipVerify, ok := opts["insecure"].(bool); ok {
|
||||||
|
transport.TLSClientConfig.InsecureSkipVerify = insecureSkipVerify
|
||||||
|
}
|
||||||
|
|
||||||
cli := &Cli{
|
cli := &Cli{
|
||||||
endpoint: url,
|
endpoint: url,
|
||||||
opts: opts,
|
opts: opts,
|
||||||
cookieFile: fmt.Sprintf("%s/.jira.d/cookies.js", homedir),
|
cookieFile: fmt.Sprintf("%s/.jira.d/cookies.js", homedir),
|
||||||
ua: &http.Client{Jar: cookieJar},
|
ua: &http.Client{
|
||||||
|
Jar: cookieJar,
|
||||||
|
Transport: transport,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
cli.ua.Jar.SetCookies(url, cli.loadCookies())
|
cli.ua.Jar.SetCookies(url, cli.loadCookies())
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ Usage:
|
|||||||
General Options:
|
General Options:
|
||||||
-b --browse Open your browser to the Jira issue
|
-b --browse Open your browser to the Jira issue
|
||||||
-e --endpoint=URI URI to use for jira
|
-e --endpoint=URI URI to use for jira
|
||||||
|
-k --insecure disable TLS certificate verification
|
||||||
-h --help Show this usage
|
-h --help Show this usage
|
||||||
-t --template=FILE Template file to use for output/editing
|
-t --template=FILE Template file to use for output/editing
|
||||||
-u --user=USER Username to use for authenticaion (default: %s)
|
-u --user=USER Username to use for authenticaion (default: %s)
|
||||||
@@ -185,6 +186,7 @@ Command Options:
|
|||||||
"editor=s": setopt,
|
"editor=s": setopt,
|
||||||
"u|user=s": setopt,
|
"u|user=s": setopt,
|
||||||
"endpoint=s": setopt,
|
"endpoint=s": setopt,
|
||||||
|
"k|insecure": setopt,
|
||||||
"t|template=s": setopt,
|
"t|template=s": setopt,
|
||||||
"q|query=s": setopt,
|
"q|query=s": setopt,
|
||||||
"p|project=s": setopt,
|
"p|project=s": setopt,
|
||||||
|
|||||||
Reference in New Issue
Block a user