I'd like to implement a secure TLS session and make sure both party has the same TLS Session ID but Go does not allow access to that information. I'm using DNS Sec and other Crypto methods to protect against Man-in-the-middle attack and this would be one of the pillar of protection. I described my sample here but I didn't find any other way except to patch the Go so I attached my four line changes.
I'm using Go 1.7.4 with environment
GOBIN=""
GOEXE=""
GOHOSTARCH="arm"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/iot/gopath"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_arm"
CC="gcc"
GOGCCFLAGS="-fPIC -marm -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build546925034=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
Patch
I used the release-branch.go1.7 branch to make it available.
diff --git a/src/crypto/tls/common.go b/src/crypto/tls/common.go
index 9fc7420..798a3c5 100644
--- a/src/crypto/tls/common.go
+++ b/src/crypto/tls/common.go
@@ -167,6 +167,7 @@ type ConnectionState struct {
VerifiedChains [][]*x509.Certificate // verified chains built from PeerCertificates
SignedCertificateTimestamps [][]byte // SCTs from the server, if any
OCSPResponse []byte // stapled OCSP response from server, if any
+ TLSSessionID string // https://tools.ietf.org/html/rfc4507#section-3.4
// TLSUnique contains the "tls-unique" channel binding value (see RFC
// 5929, section 3). For resumed sessions this value will be nil
diff --git a/src/crypto/tls/conn.go b/src/crypto/tls/conn.go
index 77fd6d3..b40667d 100644
--- a/src/crypto/tls/conn.go
+++ b/src/crypto/tls/conn.go
@@ -71,6 +71,7 @@ type Conn struct {
clientFinished [12]byte
serverFinished [12]byte
+ sessionId string
clientProtocol string
clientProtocolFallback bool
@@ -1295,6 +1296,7 @@ func (c *Conn) ConnectionState() ConnectionState {
state.ServerName = c.serverName
state.SignedCertificateTimestamps = c.scts
state.OCSPResponse = c.ocspResponse
+ state.TLSSessionID = c.sessionId
if !c.didResume {
if c.clientFinishedIsFirst {
state.TLSUnique = c.clientFinished[:]
diff --git a/src/crypto/tls/handshake_client.go b/src/crypto/tls/handshake_client.go
index f789e6f..5d6a14b 100644
--- a/src/crypto/tls/handshake_client.go
+++ b/src/crypto/tls/handshake_client.go
@@ -250,6 +250,7 @@ NextCipherSuite:
sessionCache.Put(cacheKey, hs.session)
}
+ c.sessionId = hs.serverHello.sessionId
c.didResume = isResume
c.handshakeComplete = true
c.cipherSuite = suite.id
diff --git a/src/crypto/tls/handshake_server.go b/src/crypto/tls/handshake_server.go
index 1aac729..7d92022 100644
--- a/src/crypto/tls/handshake_server.go
+++ b/src/crypto/tls/handshake_server.go
@@ -105,6 +105,7 @@ func (c *Conn) serverHandshake() error {
}
}
c.handshakeComplete = true
+ c.sessionId = hs.hello.sessionId
return nil
}
I'd like to implement a secure TLS session and make sure both party has the same TLS Session ID but Go does not allow access to that information. I'm using DNS Sec and other Crypto methods to protect against Man-in-the-middle attack and this would be one of the pillar of protection. I described my sample here but I didn't find any other way except to patch the Go so I attached my four line changes.
I'm using Go 1.7.4 with environment
Patch
I used the
release-branch.go1.7branch to make it available.