Skip to content

net/http: HTTP + TLS Handshaking documentation seems inaccurate #1956

Closed
@gopherbot

Description

@gopherbot

by jdnurmi@qwe.cc:

(Not really sure where/if there is an actual bug, but the documentation seems
inaccurate);

Documentation
=============
func (c *Conn) tls.Handshake() os.Error

... ***Most uses of this package need not call Handshake explicitly: the first Read or
Write will call it automatically ***


One would then assume an http.ListenAndServeTLS, in accumulating the request, would have
forced a handshake to occur.

Instead, I've ended up needing to create a custom listener that forces a handshake in
order to establish PeerCert data in the ConnectionState attribute.

I'm not certain this is wrong from the standpoint of TLS phrasing, but the documentation
can lead a developer to be confused.

What steps will reproduce the problem?
1.  Create a self-signed cert & key: openssl req -new -x509 -nodes  -subj
"/CN=localhost" -out host.cert
2. Compile & run attached sample
3. curl --insecure https://localhost:8443

What is the expected output?
Handshake complete

What do you see instead?
Handshake incomplete


Which compiler are you using (5g, 6g, 8g, gccgo)?
8g

Which operating system are you using?
linux

Which revision are you using?  (hg identify)
53460e066c2f+ tip

Please provide any additional information below.

I'm not convinced a code-change is needed, but someone who understands why the
documentation seems conflicting would do well to clarify it.

Attachments:

  1. tlstest.go (451 bytes)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions