File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 11package gokhttp
22
33import (
4+ "crypto/tls"
5+ "crypto/x509"
6+ "fmt"
47 "github.com/BRUHItsABunny/gOkHttp/client"
58 "net/http"
69 "os"
@@ -17,6 +20,18 @@ func TestHTTPClient(options ...gokhttp_client.Option) (*http.Client, error) {
1720 if os .Getenv ("USE_PROXY" ) == "true" {
1821 opts = append (opts , gokhttp_client .NewProxyOption (os .Getenv ("PROXY_URL" )))
1922 }
23+ if os .Getenv ("USE_MTLS" ) == "true" {
24+ opt := gokhttp_client .NewMTLSOption (x509 .NewCertPool (), []tls.Certificate {})
25+ err := opt .AddCAFromFile (os .Getenv ("CA_CERT" ))
26+ if err != nil {
27+ return nil , fmt .Errorf ("opt.AddCAFromFile: %w" , err )
28+ }
29+ err = opt .AddClientCertFromFile (os .Getenv ("CLIENT_CERT" ), os .Getenv ("CLIENT_KEY" ))
30+ if err != nil {
31+ return nil , fmt .Errorf ("opt.AddClientCertFromFile: %w" , err )
32+ }
33+ opts = append (opts , opt )
34+ }
2035
2136 opts = append (opts , options ... )
2237
You can’t perform that action at this time.
0 commit comments