Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

golang: Send http request with certificate

Tags:

https

go

For first I am newbie in golang.

I try to send https request. I create http.Client like this:

func httpClient(c *Config) (httpClient *http.Client) {
cert, _ := tls.LoadX509KeyPair(c.CertFile, c.KeyFile)

ssl := &tls.Config{
    Certificates:       []tls.Certificate{cert},
    InsecureSkipVerify: true,
}

ssl.Rand = rand.Reader
return &http.Client{
    Transport: &http.Transport{
        TLSClientConfig: ssl,
    },
}
}

But as result I get local error: no renegotiation.

Thanks for any help!

like image 920
Sergey Gernyak Avatar asked Jun 30 '14 18:06

Sergey Gernyak


2 Answers

This is likely a problem with the remote server you're accessing, but it is a known problem (with Microsoft Azure services for one).

There may be a workaround on the way for go1.4, but until then the go client still doesn't support TLS renegotiation.

Relevant issue: https://code.google.com/p/go/issues/detail?id=5742

like image 96
JimB Avatar answered Oct 22 '22 14:10

JimB


It looks as though renegotiation (and client certificate authentication) was previously unsupported. This looks to have been fixed by commit https://github.com/golang/go/commit/af125a5193c75dd59307fcf1b26d885010ce8bfd

like image 30
Gov Avatar answered Oct 22 '22 15:10

Gov