Skip to content

Commit

Permalink
Merge pull request #11 from kubescape/skip-ssl-verification
Browse files Browse the repository at this point in the history
skip ssl verification
  • Loading branch information
amirmalka authored Jun 30, 2024
2 parents a6de4ec + 601ab2a commit 1e21608
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions request.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"bytes"
"crypto/tls"
"flag"
"fmt"
"net/http"
Expand All @@ -15,11 +16,12 @@ import (
)

type FlagParser struct {
fullURL url.URL
pathToBody string
headers string
method string
pathToOutput string
fullURL url.URL
pathToBody string
headers string
method string
pathToOutput string
skipSSLVerify bool
}

func NewFlagParser() *FlagParser {
Expand All @@ -37,6 +39,7 @@ func (f *FlagParser) parser() {
flag.StringVar(&f.pathToBody, "path-body", "", "path to body")
flag.StringVar(&f.headers, "headers", "", "http headers")
flag.StringVar(&f.pathToOutput, "path-output", "", "path to output file")
flag.BoolVar(&f.skipSSLVerify, "skip-ssl-verify", false, "skip SSL verification")

flag.Parse()

Expand Down Expand Up @@ -114,9 +117,22 @@ func Request(f *FlagParser) (string, error) {

setHeaders(req, headers)

resp, err = http.DefaultClient.Do(req)
if err != nil {
return "", err
if f.skipSSLVerify {
fmt.Printf("skipping SSL verification\n")
client := &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
},
}
resp, err = client.Do(req)
if err != nil {
return "", err
}
} else {
resp, err = http.DefaultClient.Do(req)
if err != nil {
return "", err
}
}

strResp, e := httputils.HttpRespToString(resp)
Expand Down

0 comments on commit 1e21608

Please sign in to comment.