Skip to content

Commit

Permalink
Merge pull request #13 from libp2p/better-type-checking
Browse files Browse the repository at this point in the history
avoid using interface{} when generating certificates
  • Loading branch information
marten-seemann authored Feb 17, 2019
2 parents 936688b + 10b3e2a commit 517ac00
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions p2p/security/tls/crypto.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package libp2ptls

import (
"crypto"
"crypto/rand"
"crypto/tls"
"crypto/x509"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 517ac00

Please sign in to comment.