Skip to content

Commit dfb7265

Browse files
author
Chris Sexton
committed
Fixes astaxie#21, add flag to optionally support unverified SSL requests
1 parent 2b38c08 commit dfb7265

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

bat.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package main
1818

1919
import (
20+
"crypto/tls"
2021
"encoding/json"
2122
"flag"
2223
"fmt"
@@ -38,6 +39,7 @@ var (
3839
form bool
3940
pretty bool
4041
download bool
42+
insecureSSL bool
4143
auth string
4244
proxy string
4345
printV string
@@ -60,6 +62,8 @@ func init() {
6062
flag.BoolVar(&form, "f", false, "Submitting as a form")
6163
flag.BoolVar(&download, "download", false, "Download the url content as file")
6264
flag.BoolVar(&download, "d", false, "Download the url content as file")
65+
flag.BoolVar(&insecureSSL, "insecure", false, "Allow connections to SSL sites without certs")
66+
flag.BoolVar(&insecureSSL, "k", false, "Allow connections to SSL sites without certs")
6367
flag.StringVar(&auth, "auth", "", "HTTP authentication username:password, USER[:PASS]")
6468
flag.StringVar(&auth, "a", "", "HTTP authentication username:password, USER[:PASS]")
6569
flag.StringVar(&proxy, "proxy", "", "Proxy host and port, PROXY_URL")
@@ -129,6 +133,10 @@ func main() {
129133
password, _ := u.User.Password()
130134
httpreq.GetRequest().SetBasicAuth(u.User.Username(), password)
131135
}
136+
// Insecure SSL Support
137+
if insecureSSL {
138+
httpreq.SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true})
139+
}
132140
// Proxy Support
133141
if proxy != "" {
134142
purl, err := url.Parse(proxy)
@@ -298,6 +306,7 @@ flags:
298306
-f, -form=false Submitting the data as a form
299307
-j, -json=true Send the data in a JSON object
300308
-p, -pretty=true Print Json Pretty Fomat
309+
-k, -insecure Allow connections to SSL sites without certs
301310
-proxy=PROXY_URL Proxy with host and port
302311
-print="A" String specifying what the output should contain, default will print all infomation
303312
"H" request headers

0 commit comments

Comments
 (0)