Created
March 28, 2022 16:16
-
-
Save myleshorton/1d79a9f444d1c0fabfb3a9e94400bc17 to your computer and use it in GitHub Desktop.
Using TLS without DNS
This file contains hidden or 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 ( | |
"context" | |
"crypto/tls" | |
"fmt" | |
"net" | |
"net/http" | |
) | |
func main() { | |
client := &http.Client{ | |
Transport: &http.Transport{ | |
DialTLSContext: func(ctx context.Context, network, addr string) (net.Conn, error) { | |
conf := &tls.Config{ | |
ServerName: "google.com", | |
} | |
return tls.Dial("tcp", "142.250.64.110:443", conf) | |
}, | |
}, | |
} | |
res, err := client.Get("https://google.com") | |
if err != nil { | |
fmt.Printf("%v\n", err) | |
return | |
} | |
defer res.Body.Close() | |
fmt.Printf("%s\n", res.Status) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment