Skip to content

Commit

Permalink
Add insecure option for TLS endpoints
Browse files Browse the repository at this point in the history
This gives the option of disabling TLS certificate verification for
the server.

Closes #25
  • Loading branch information
blalor committed Jan 21, 2016
1 parent 6734532 commit 6a88bb9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 13 additions & 1 deletion cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"net/http"
"net/http/cookiejar"
"net/url"
"crypto/tls"
"os"
"os/exec"
"runtime"
Expand All @@ -36,15 +37,26 @@ func New(opts map[string]interface{}) *Cli {
endpoint, _ := opts["endpoint"].(string)
url, _ := url.Parse(strings.TrimRight(endpoint, "/"))

transport := &http.Transport{
TLSClientConfig: &tls.Config{},
}

if project, ok := opts["project"].(string); ok {
opts["project"] = strings.ToUpper(project)
}

if insecureSkipVerify, ok := opts["insecure"].(bool); ok {
transport.TLSClientConfig.InsecureSkipVerify = insecureSkipVerify
}

cli := &Cli{
endpoint: url,
opts: opts,
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())
Expand Down
2 changes: 2 additions & 0 deletions main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ Usage:
General Options:
-b --browse Open your browser to the Jira issue
-e --endpoint=URI URI to use for jira
-k --insecure disable TLS certificate verification
-h --help Show this usage
-t --template=FILE Template file to use for output/editing
-u --user=USER Username to use for authenticaion (default: %s)
Expand Down Expand Up @@ -185,6 +186,7 @@ Command Options:
"editor=s": setopt,
"u|user=s": setopt,
"endpoint=s": setopt,
"k|insecure": setopt,
"t|template=s": setopt,
"q|query=s": setopt,
"p|project=s": setopt,
Expand Down

0 comments on commit 6a88bb9

Please sign in to comment.