-
-
Save braised-babbage/374890bfd28edfb9a69ac2a3a07b8d6a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"crypto/tls" | |
"fmt" | |
"io" | |
"log" | |
"net/http" | |
"os" | |
) | |
func main() { | |
keylogPath := os.Getenv("SSLKEYLOGFILE") | |
var keylogWriter io.Writer | |
if keylogPath != "" { | |
f, err := os.OpenFile(keylogPath, os.O_WRONLY|os.O_CREATE, 0600) | |
if err != nil { | |
log.Fatalf("failed to open keylog file: %v", err) | |
} | |
defer f.Close() | |
keylogWriter = f | |
} | |
tlsConfig := &tls.Config{ | |
InsecureSkipVerify: true, | |
KeyLogWriter: keylogWriter, | |
} | |
transport := &http.Transport{ | |
TLSClientConfig: tlsConfig, | |
ForceAttemptHTTP2: true, | |
MaxConnsPerHost: 1, | |
} | |
client := &http.Client{ | |
Transport: transport, | |
} | |
resp, err := client.Get("https://localhost:8443") | |
if err != nil { | |
log.Fatalf("failed to make request: %v", err) | |
} | |
defer resp.Body.Close() | |
fmt.Printf("response status: %s\n", resp.Status) | |
resp, err = client.Get("https://localhost:8443") | |
if err != nil { | |
log.Fatalf("failed to make request: %v", err) | |
} | |
defer resp.Body.Close() | |
fmt.Printf("response status: %s\n", resp.Status) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment