From 10b3e2a26565ffcc709bd22017b77b00aaab6b6a Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Sun, 10 Feb 2019 15:06:26 +0800 Subject: [PATCH] avoid using interface{} when generating certificates --- p2p/security/tls/crypto.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/p2p/security/tls/crypto.go b/p2p/security/tls/crypto.go index 583fe39c14..23178fa9ab 100644 --- a/p2p/security/tls/crypto.go +++ b/p2p/security/tls/crypto.go @@ -1,6 +1,7 @@ package libp2ptls import ( + "crypto" "crypto/rand" "crypto/tls" "crypto/x509" @@ -104,7 +105,7 @@ func getRemotePubKey(chain []*x509.Certificate) (ic.PubKey, error) { } } -func keyToCertificate(sk ic.PrivKey) (interface{}, *x509.Certificate, error) { +func keyToCertificate(sk ic.PrivKey) (crypto.PrivateKey, *x509.Certificate, error) { sn, err := rand.Int(rand.Reader, big.NewInt(1<<62)) if err != nil { return nil, nil, err @@ -115,7 +116,8 @@ func keyToCertificate(sk ic.PrivKey) (interface{}, *x509.Certificate, error) { NotAfter: time.Now().Add(certValidityPeriod), } - var publicKey, privateKey interface{} + var privateKey crypto.PrivateKey + var publicKey crypto.PublicKey keyBytes, err := sk.Bytes() if err != nil { return nil, nil, err