-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
crypto/tls: add Dialer with Dial, DialContext methods #18482
Comments
The review period for Go 1.7 APIs ended 6 months ago. The review period for Go 1.8 APIs ended approximately 3 weeks ago. We can consider something new in crypto/tls for Go 1.9. For now, you'll just have to dial first, and then use https://golang.org/pkg/crypto/tls/#Client to start the client handshake on the already-connected TCP (or whatever) Conn. |
I believe I have a use-case for this feature and would be curious if there's a suggested work-around. We're trying to configure a Edit: perhaps I'm asking in the wrong issue -- this is bigger than just the |
Hello! Sorry for "pinging", but will this issue be landed in |
@gobwas There has been no definite decision to implement this, and there is no patch. At this point I would say that it is unlikely to be fixed for 1.10. Sorry. |
Change https://golang.org/cl/93255 mentions this issue: |
Is there currently a workaround for this issue? |
@maja42 As @akalin-keybase said
I submitted a patch implementing this a few months ago but I'm not sure if there's a decision to add this to the API. @bradfitz is there a decision one way or the other? |
@FiloSottile, I'm going to remove the Proposal-Crypto review so this gets some attention during the proposal review meetings (which exclude Crypto). This is more standard library API than it is crypto, and you also seem to be backlogged on other crypto stuff. |
Counter proposal: What if we add a new // Dialer dials TLS connections given a configuration and a Dialer for the
// underlying connection.
type Dialer struct {
Config *Config
NetDialer *net.Dialer
} Then the new Thoughts? |
If this is approved, I'll implement it in the TLS 1.3 dev cycle. |
Works for me! |
Another possibility: What about adding a
|
@jsha, that would violate the context rules of not storing them in long-lived or shared structures, and *tls.Config is generally both. I don't understand your handshake concern: we already do the handshake under the provided timeout. That wouldn't change with the design proposed above. The handshake would still be under the context's deadline. |
Ah, good point. I was looking primarily at the conn.Client method, where
The Handshake concern applies only in code where you build your own TCP connection then hand it off to
It's not strictly related to implementing |
Nevermind on this; I looked again and realized that yes, clients will typically reuse a |
Any progress on this issue ? |
Should the methods on
Also, we should probably allow |
Seeing as the two existing TLS dial functions ( |
@bradfitz points out that net/http.Transport has function fields that would be type-matched by these methods if we made them return net.Conn instead of *tls.Conn. So probably we should return net.Conn here. We could still document that the underlying type is *tls.Conn. Otherwise this seems like a likely accept based on the discussion above. Leaving open for a week for final comments. |
(I think that's referring to #21526 ?) |
@rosenhouse, yes, the point is that if this tls.Dialer's Dial and DialContext methods return net.Conn (not *tls.Conn), then you can do assignments like this without adapters:
|
Change https://golang.org/cl/214977 mentions this issue: |
No change in consensus, so accepted. |
In go 1.7,
Dialer
now has DialContext, which takes acontext.Context
and uses it for expiration.However,
DialWithDialer
just callsDial
on its givenDialer
, and doesn't take acontext.Context
.To be backwards compatible, probably need to provide a separate function, say,
DialContextWithDialer
, that is likeDialWithDialer
except it takes acontext.Context
and callsDialContext
, and haveDialWithDialer
callDialContextWithDialer
withcontext.Background()
.It looks like as a workaround, callers can write their own
DialContextWithDialer
function and copy most ofDialWithDialer
.The text was updated successfully, but these errors were encountered: