Skip to content

Instantly share code, notes, and snippets.

@sthorne
Created June 3, 2016 19:41
Show Gist options
  • Save sthorne/a2de3986a297519b9010696762c6f811 to your computer and use it in GitHub Desktop.
Save sthorne/a2de3986a297519b9010696762c6f811 to your computer and use it in GitHub Desktop.
Fetch an HTTPS Asset from Specific IP and Skipping DNS lookup
package main
import (
"crypto/tls"
"log"
"net/http"
)
func main() {
tlsConfig := &tls.Config{
ServerName: "moupon.co",
}
tlsConfig.BuildNameToCertificate()
transport := &http.Transport{TLSClientConfig: tlsConfig}
client := &http.Client{Transport: transport}
req, err := http.NewRequest("GET", "https://216.239.32.21/s/img/logo.png", nil)
if err != nil {
log.Fatal(err)
}
req.Host = "moupon.co"
_, err = client.Do(req)
if err != nil {
log.Fatal(err)
}
log.Fatal("no errors")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment