net/http: support adding client certificate also for http/2 #18017
Labels
Milestone
Comments
We should document this better in the godoc, but otherwise this is WAI. If you explicitly want HTTP/2 you need to use the |
@bradfitz Thanks, that documentation will surely help. I guess when it's mature, the http2 will be included into the standard lib as well. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
What version of Go are you using (
go version
)?1.7.3
What operating system and processor architecture are you using (
go env
)?darwin amd64
What did you do?
My first attempt to use a TLS client certificate for authenticating towards a http/2 only server looked something like this:
This code results in a HTTP/1.1 transport.
My 2nd attempt was to also define the
NextProto
:What did you expect to see?
I expected the http/2 upgrade to work seamlessly even with my custom client certificate specified.
This is how I've been authenticating with previous HTTP versions, I didn't expect the API to change.
What did you see instead?
Since the targeted server only supports HTTP/2, the returned request error was rather confusing:
malformed HTTP status code "client"
.After reading the source of how the transport handling works for h2, I found these lines in net/http/transport.go:
It refers to http2.ConfigureTransport, which is part of the external import
golang.org/x/net/http2
.Importing and using this on my transport indeed fixed my problem.
To my surprise, I could not find any exported functionality in the standard library like this. I feel that it should be there, to make the http/2 client support complete.
The text was updated successfully, but these errors were encountered: