Skip to content

crypto/tls: allow access to net.Conn underneath tls.Conn #29257

Closed

Description

@ja-nixi

Currently it is not possible to access FD in tls.Conn
in tls.Conn the underlying net.Conn is not accessible except in ClientHelloInfo

Senario:
in net/http we can't access the FD for https connections but we can access it for http connections
in a WebSocket connection after Hijack, when the connection is http we can use netpoll but when its https we can't

the only workaround right now is using a https to http proxy but it's not efficient as exposing the net.Conn on tls.Conn

/cc @FiloSottile

Activity

  1. ja-nixi commented on Dec 17, 2018

    @ja-nixi
    Author
  2. added
    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
    FeatureRequestIssues asking for a new feature that does not need a proposal.
    on Dec 17, 2018
  3. added this to the Go1.13 milestone on Dec 17, 2018
  4. bradfitz commented on Dec 17, 2018

    @bradfitz
    Contributor
  5. changed the title [-]crypto/tls: allow access to file descriptor for tls.Conn[/-] [+]proposal: crypto/tls: allow access to file descriptor for tls.Conn[/+] on Mar 7, 2019
  6. odeke-em commented on Mar 7, 2019

    @odeke-em
    Member

    I have marked this as a proposal for it to get the proposal treatment.

  7. ianlancetaylor commented on Mar 20, 2019

    @ianlancetaylor
    Contributor

    What do you actually want to do with the file descriptor?

  8. added
    WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.
    on Mar 20, 2019
  9. added
    Proposal-CryptoProposal related to crypto packages or other security issues
    on Mar 27, 2019
  10. gopherbot commented on Apr 20, 2019

    @gopherbot
    Contributor

    Timed out in state WaitingForInfo. Closing.

    (I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

  11. blakerouse commented on Jun 1, 2019

    @blakerouse

    It is useful to get the underlying connections file descriptor so that it can be passed into a syscall for epoll. This removes the needed to start a go routine for every websocket connection.

    In my concurrent-websocket module I need to do just that so multiple websocket connections can be multiplexed through a pool of goroutines. I am currently working around this issue by using reflect and unsafe, which is really bad!

    L26 below shows how I am getting the connection, and you can see on L45 how I pass that connection to netpoll.HandleReadOnce. It still uses the tls.Conn for reading and writing, but needs to pass the underlying connection for epoll to work.

    https://github.com/blakerouse/concurrent-websocket/blob/master/channel.go#L26

  12. BernhardValenti commented on Feb 4, 2020

    @BernhardValenti

    This is also an issue when using TLS with the new http.Server ConnContext callback, in my case I want to get syscall.TCPInfo for each connection.

    http.Server{
    	ConnContext: func(ctx context.Context, c net.Conn) context.Context {
    		// c is a tls.Conn, with apparently no way to access the actual connection
    		return
    	},
    }
  13. 45 remaining items

  14. rsc commented on May 12, 2021

    @rsc
    Contributor

    No change in consensus, so accepted. 🎉
    This issue now tracks the work of implementing the proposal.
    — rsc for the proposal review group

  15. changed the title [-]proposal: crypto/tls: allow access to net.Conn underneath tls.Conn[/-] [+]crypto/tls: allow access to net.Conn underneath tls.Conn[/+] on May 12, 2021
  16. modified the milestones: Proposal, Backlog on May 12, 2021
  17. jarrettyeo commented on May 19, 2021

    @jarrettyeo

    @rsc Thank you for fixing this, when will this issue be resolved?

  18. gopherbot commented on Jun 5, 2021

    @gopherbot
    Contributor

    Change https://golang.org/cl/325250 mentions this issue: crypto/tls: add NetConn method

  19. added a commit that references this issue on Oct 18, 2021
  20. moved this to Accepted in Proposalson Aug 10, 2022
  21. locked and limited conversation to collaborators on Oct 25, 2022
  22. removed this from Proposalson Oct 26, 2022
  23. added a commit that references this issue on Sep 19, 2024
    f47335e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ 换网址