From f47335e653ac37f68ada2b265ce4a2c869a27cae Mon Sep 17 00:00:00 2001 From: Agniva De Sarker Date: Sat, 5 Jun 2021 11:04:37 +0530 Subject: [PATCH] crypto/tls: add Conn.NetConn method NetConn method gives us access to the underlying net.Conn value. Fixes #29257 Change-Id: I68b2a92ed9dab4be9900807c94184f8c0aeb4f72 Reviewed-on: https://go-review.googlesource.com/c/go/+/325250 Reviewed-by: Filippo Valsorda Trust: Agniva De Sarker Trust: Katie Hockman --- src/crypto/tls/conn.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/crypto/tls/conn.go b/src/crypto/tls/conn.go index 969f357834..300e9a233c 100644 --- a/src/crypto/tls/conn.go +++ b/src/crypto/tls/conn.go @@ -151,6 +151,13 @@ func (c *Conn) SetWriteDeadline(t time.Time) error { return c.conn.SetWriteDeadline(t) } +// NetConn returns the underlying connection that is wrapped by c. +// Note that writing to or reading from this connection directly will corrupt the +// TLS session. +func (c *Conn) NetConn() net.Conn { + return c.conn +} + // A halfConn represents one direction of the record layer // connection, either sending or receiving. type halfConn struct { -- 2.50.0