From e0b7ab9ccbbf802fd6d451162007ac2f278c5b75 Mon Sep 17 00:00:00 2001 From: John Brooks Date: Sun, 24 Sep 2017 14:23:41 -0600 Subject: [PATCH] core: Fix generation of new onion keys Bulb is rather picky about what it receives when generating new keys. --- core/network.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/core/network.go b/core/network.go index 56f96d8..a20c092 100644 --- a/core/network.go +++ b/core/network.go @@ -2,6 +2,7 @@ package core import ( "crypto" + "crypto/rsa" "errors" "github.com/ricochet-im/ricochet-go/core/utils" "github.com/ricochet-im/ricochet-go/rpc" @@ -340,12 +341,13 @@ func (n *Network) getConnection() *bulb.Conn { // is lost and reconnected, the service will be re-added automatically. // BUG(special): Errors that occur after reconnecting cannot be detected. func (n *Network) AddOnionPorts(ports []bulb.OnionPortSpec, key crypto.PrivateKey) (*OnionService, error) { + // Treat nil *rsa.PrivateKey as nil + if v, ok := key.(*rsa.PrivateKey); ok && v == nil { + key = nil + } if key == nil { - // Ask for a new key, force RSA1024 - key = &bulb.OnionPrivateKey{ - KeyType: "NEW", - Key: "RSA1024", - } + // Ask for a new key + key = &bulb.OnionPrivateKey{} } conn := n.getConnection()