0
0
mirror of https://github.com/thegeeklab/wp-plugin-go.git synced 2024-11-25 09:30:39 +00:00

Expose whether SSL verification is skipped

This commit is contained in:
Don 2019-12-18 15:37:07 -08:00
parent 8fb8284d71
commit b771a2a224

View File

@ -30,6 +30,9 @@ type Network struct {
// Client for making network requests. // Client for making network requests.
Client *http.Client Client *http.Client
/// Whether SSL verification is skipped
SkipVerify bool
} }
const networkSkipVerifyFlag = "transport.skip-verify" const networkSkipVerifyFlag = "transport.skip-verify"
@ -61,7 +64,8 @@ func NetworkFromContext(ctx *cli.Context) Network {
ExpectContinueTimeout: 1 * time.Second, ExpectContinueTimeout: 1 * time.Second,
} }
if ctx.Bool(networkSkipVerifyFlag) { skipVerify := ctx.Bool(networkSkipVerifyFlag)
if skipVerify {
logrus.Warning("ssl verification is turned off") logrus.Warning("ssl verification is turned off")
transport.TLSClientConfig = &tls.Config{ transport.TLSClientConfig = &tls.Config{
InsecureSkipVerify: true, InsecureSkipVerify: true,
@ -80,5 +84,6 @@ func NetworkFromContext(ctx *cli.Context) Network {
Transport: transport, Transport: transport,
}, },
Context: context, Context: context,
SkipVerify: skipVerify,
} }
} }