Skip to content

Commit

Permalink
Update main.go
Browse files Browse the repository at this point in the history
  • Loading branch information
allthingsclowd authored Feb 2, 2020
1 parent 86f9b2a commit c5464b8
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,32 @@ func queryVault(vaultAddress string, url string, token string, data map[string]i
req.Header.Set("X-Vault-Token", token)
req.Header.Set("Content-Type", "application/json")

client := &http.Client{}
resp, err := client.Do(req)
//client := &http.Client{}
// Load client cert
cert, err := tls.LoadX509KeyPair(*vcertFile, *vkeyFile)
if err != nil {
log.Fatal(err)
}

// Load CA cert
caCert, err := ioutil.ReadFile(*vcaFile)
if err != nil {
log.Fatal(err)
}
caCertPool := x509.NewCertPool()
caCertPool.AppendCertsFromPEM(caCert)

// Setup HTTPS client
tlsConfig := &tls.Config{
Certificates: []tls.Certificate{cert},
RootCAs: caCertPool,
// InsecureSkipVerify: true,
}
tlsConfig.BuildNameToCertificate()
transport := &http.Transport{TLSClientConfig: tlsConfig}
httpClient := &http.Client{Transport: transport}

resp, err := httpClient.Do(req)
if err != nil {
panic(err)
}
Expand Down

0 comments on commit c5464b8

Please sign in to comment.