server: Don't always assume TLS is used
This commit is contained in:
parent
df1794c803
commit
c329a2487e
17
server.go
17
server.go
@ -204,14 +204,17 @@ func (s *Server) respond(conn net.Conn) {
|
|||||||
w.WriteStatus(StatusBadRequest)
|
w.WriteStatus(StatusBadRequest)
|
||||||
} else {
|
} else {
|
||||||
// Store information about the TLS connection
|
// Store information about the TLS connection
|
||||||
connState := conn.(*tls.Conn).ConnectionState()
|
var connState tls.ConnectionState
|
||||||
var cert *tls.Certificate
|
var cert *tls.Certificate
|
||||||
if len(connState.PeerCertificates) > 0 {
|
if tlsConn, ok := conn.(*tls.Conn); ok {
|
||||||
peerCert := connState.PeerCertificates[0]
|
connState = tlsConn.ConnectionState()
|
||||||
// Store the TLS certificate
|
if len(connState.PeerCertificates) > 0 {
|
||||||
cert = &tls.Certificate{
|
peerCert := connState.PeerCertificates[0]
|
||||||
Certificate: [][]byte{peerCert.Raw},
|
// Store the TLS certificate
|
||||||
Leaf: peerCert,
|
cert = &tls.Certificate{
|
||||||
|
Certificate: [][]byte{peerCert.Raw},
|
||||||
|
Leaf: peerCert,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user