@@ -66,9 +66,7 @@ func (i *Identity) ConfigForAny() (*tls.Config, <-chan ic.PubKey) {
66
66
//
67
67
// It should be used to create a new tls.Config before securing either an
68
68
// incoming or outgoing connection.
69
- func (i * Identity ) ConfigForPeer (
70
- remote peer.ID ,
71
- ) (* tls.Config , <- chan ic.PubKey ) {
69
+ func (i * Identity ) ConfigForPeer (remote peer.ID ) (* tls.Config , <- chan ic.PubKey ) {
72
70
keyCh := make (chan ic.PubKey , 1 )
73
71
// We need to check the peer ID in the VerifyPeerCertificate callback.
74
72
// The tls.Config it is also used for listening, and we might also have concurrent dials.
@@ -88,7 +86,7 @@ func (i *Identity) ConfigForPeer(
88
86
chain [i ] = cert
89
87
}
90
88
91
- pubKey , err := getRemotePubKey (chain )
89
+ pubKey , err := PubKeyFromCertChain (chain )
92
90
if err != nil {
93
91
return err
94
92
}
@@ -101,8 +99,8 @@ func (i *Identity) ConfigForPeer(
101
99
return conf , keyCh
102
100
}
103
101
104
- // getRemotePubKey derives the remote's public key from the certificate chain .
105
- func getRemotePubKey (chain []* x509.Certificate ) (ic.PubKey , error ) {
102
+ // PubKeyFromCertChain verifies the certificate chain and extract the remote's public key .
103
+ func PubKeyFromCertChain (chain []* x509.Certificate ) (ic.PubKey , error ) {
106
104
if len (chain ) != 1 {
107
105
return nil , errors .New ("expected one certificates in the chain" )
108
106
}
0 commit comments