tls: move PeerCertificates to ConnectionState
R=agl, agl1 CC=golang-dev, rsc https://golang.org/cl/4248078
This commit is contained in:
parent
6e38ce296e
commit
36cddf2fc1
@ -7,6 +7,7 @@ package tls
|
|||||||
import (
|
import (
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"crypto/rsa"
|
"crypto/rsa"
|
||||||
|
"crypto/x509"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"sync"
|
"sync"
|
||||||
@ -95,6 +96,9 @@ type ConnectionState struct {
|
|||||||
HandshakeComplete bool
|
HandshakeComplete bool
|
||||||
CipherSuite uint16
|
CipherSuite uint16
|
||||||
NegotiatedProtocol string
|
NegotiatedProtocol string
|
||||||
|
|
||||||
|
// the certificate chain that was presented by the other side
|
||||||
|
PeerCertificates []*x509.Certificate
|
||||||
}
|
}
|
||||||
|
|
||||||
// A Config structure is used to configure a TLS client or server. After one
|
// A Config structure is used to configure a TLS client or server. After one
|
||||||
|
10
conn.go
10
conn.go
@ -762,6 +762,7 @@ func (c *Conn) ConnectionState() ConnectionState {
|
|||||||
if c.handshakeComplete {
|
if c.handshakeComplete {
|
||||||
state.NegotiatedProtocol = c.clientProtocol
|
state.NegotiatedProtocol = c.clientProtocol
|
||||||
state.CipherSuite = c.cipherSuite
|
state.CipherSuite = c.cipherSuite
|
||||||
|
state.PeerCertificates = c.peerCertificates
|
||||||
}
|
}
|
||||||
|
|
||||||
return state
|
return state
|
||||||
@ -776,15 +777,6 @@ func (c *Conn) OCSPResponse() []byte {
|
|||||||
return c.ocspResponse
|
return c.ocspResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
// PeerCertificates returns the certificate chain that was presented by the
|
|
||||||
// other side.
|
|
||||||
func (c *Conn) PeerCertificates() []*x509.Certificate {
|
|
||||||
c.handshakeMutex.Lock()
|
|
||||||
defer c.handshakeMutex.Unlock()
|
|
||||||
|
|
||||||
return c.peerCertificates
|
|
||||||
}
|
|
||||||
|
|
||||||
// VerifyHostname checks that the peer certificate chain is valid for
|
// VerifyHostname checks that the peer certificate chain is valid for
|
||||||
// connecting to host. If so, it returns nil; if not, it returns an os.Error
|
// connecting to host. If so, it returns nil; if not, it returns an os.Error
|
||||||
// describing the problem.
|
// describing the problem.
|
||||||
|
Loading…
Reference in New Issue
Block a user