hpkp icon indicating copy to clipboard operation
hpkp copied to clipboard

hpkp Dialer compatability with HTTP2

Open ghost opened this issue 6 years ago • 0 comments

Trying to use your dialer against http2.Transport seems to fail Looks like http2.Transport.DialTLS expects

type Transport struct {
...
DialTLS func(network, addr string, cfg *tls.Config) (net.Conn, error)

See: https://github.com/golang/net/blob/master/http2/transport.go

Where your DialTLS doesn't accept a tls.Config

https://github.com/tam7t/hpkp/blob/master/dialer.go

My Error:

./https.go:63: cannot use hpkpDialConf.NewDialer() (type func(string, string) (net.Conn, error)) as type func(string, string, *tls.Config) (net.Conn, error) in assignment

Code is here: https://github.com/GinoM/dingo/tree/hpkp-pinning

Your code works fine against http.Transport though.

I feel like there is probably a better solution but maybe you can add something like

func (c *DialerConfig) NewDialer2() func(network, addr string, cfg *tls.Config) (net.Conn, error) {
        c.TLSConfig = cfg
	reporter := c.Reporter
	if reporter == nil {
		reporter = emptyReporter
	}

	return newPinDialer(c.Storage, reporter, c.PinOnly, c.TLSConfig)
}```

ghost avatar Jul 15 '17 18:07 ghost