You can enable certificate pinning for a TLS-Client instance. You need to provide a map of pins by host when you create the client. See the example code below
This example code shows how to enabled certificate pinning for bstn.com. Next to it you can supply a BadPinHandler function as second argument for the WithCertificatePinning option.
The default BadPinHandler looks like this. This function will be executed when a bad pin is detected:
var DefaultBadPinHandler = func(req *http.Request) {
fmt.Println("this is the default bad pin handler")
}
Shared Library & Standalone API
When using the shared library you can supply certificate pinning settings via the "certificatePinningHosts" field. This should look similar to this:
You can easilly generate pins with this helpful tool: https://github.com/tam7t/hpkp
Just install the tool and run the following command against the site you want to generate pins for: