@@ -4,6 +4,7 @@ package main
4
4
5
5
import (
6
6
"bufio"
7
+ "crypto/tls"
7
8
"fmt"
8
9
"io"
9
10
"io/ioutil"
@@ -28,6 +29,7 @@ type options struct {
28
29
help bool
29
30
warc bool
30
31
rawInput bool
32
+ certCheck bool
31
33
32
34
// urls
33
35
includeSource bool
@@ -92,6 +94,7 @@ func init() {
92
94
" -P, --placeholder string Set the expression placeholder to a custom string (default 'EXPR')" ,
93
95
" -j, --raw-input Read raw JavaScript source from stdin" ,
94
96
" -w, --warc Treat the input files as WARC (Web ARChive) files" ,
97
+ " -i, --no-check-certificate Ignore validation of server certificates" ,
95
98
"" ,
96
99
"URLs mode:" ,
97
100
" -I, --ignore-strings Ignore matches from string literals" ,
@@ -130,6 +133,7 @@ func main() {
130
133
flag .StringVarP (& opts .placeholder , "placeholder" , "P" , "EXPR" , "Set the expression placeholder to a custom string" )
131
134
flag .BoolVarP (& opts .help , "help" , "h" , false , "" )
132
135
flag .BoolVarP (& opts .warc , "warc" , "w" , false , "" )
136
+ flag .BoolVarP (& opts .certCheck , "no-check-certificate" , "i" , false , "Ignore validation of server certificates" )
133
137
134
138
// url options
135
139
flag .BoolVarP (& opts .includeSource , "include-source" , "S" , false , "Include the source code where the URL was found" )
@@ -230,7 +234,7 @@ func main() {
230
234
continue
231
235
}
232
236
233
- source , err := readFromFileOrURL (filename , opts .cookie , opts .headers )
237
+ source , err := readFromFileOrURL (filename , opts .cookie , opts .headers , opts . certCheck )
234
238
if err != nil {
235
239
errs <- err
236
240
continue
@@ -288,10 +292,14 @@ func main() {
288
292
289
293
}
290
294
291
- func readFromFileOrURL (path string , cookie string , headers []string ) ([]byte , error ) {
295
+ func readFromFileOrURL (path string , cookie string , headers []string , ignoreCert bool ) ([]byte , error ) {
292
296
if strings .HasPrefix (path , "http://" ) || strings .HasPrefix (path , "https://" ) {
293
297
client := & http.Client {}
294
298
299
+ if ignoreCert {
300
+ client .Transport = & http.Transport {TLSClientConfig : & tls.Config {InsecureSkipVerify : true }}
301
+ }
302
+
295
303
req , err := http .NewRequest ("GET" , path , nil )
296
304
if err != nil {
297
305
return nil , err
0 commit comments