core: Fix generation of new onion keys
Bulb is rather picky about what it receives when generating new keys.
This commit is contained in:
parent
b5301c2782
commit
e0b7ab9ccb
|
@ -2,6 +2,7 @@ package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto"
|
"crypto"
|
||||||
|
"crypto/rsa"
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/ricochet-im/ricochet-go/core/utils"
|
"github.com/ricochet-im/ricochet-go/core/utils"
|
||||||
"github.com/ricochet-im/ricochet-go/rpc"
|
"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.
|
// is lost and reconnected, the service will be re-added automatically.
|
||||||
// BUG(special): Errors that occur after reconnecting cannot be detected.
|
// BUG(special): Errors that occur after reconnecting cannot be detected.
|
||||||
func (n *Network) AddOnionPorts(ports []bulb.OnionPortSpec, key crypto.PrivateKey) (*OnionService, error) {
|
func (n *Network) AddOnionPorts(ports []bulb.OnionPortSpec, key crypto.PrivateKey) (*OnionService, error) {
|
||||||
if key == nil {
|
// Treat nil *rsa.PrivateKey as nil
|
||||||
// Ask for a new key, force RSA1024
|
if v, ok := key.(*rsa.PrivateKey); ok && v == nil {
|
||||||
key = &bulb.OnionPrivateKey{
|
key = nil
|
||||||
KeyType: "NEW",
|
|
||||||
Key: "RSA1024",
|
|
||||||
}
|
}
|
||||||
|
if key == nil {
|
||||||
|
// Ask for a new key
|
||||||
|
key = &bulb.OnionPrivateKey{}
|
||||||
}
|
}
|
||||||
|
|
||||||
conn := n.getConnection()
|
conn := n.getConnection()
|
||||||
|
|
Loading…
Reference in New Issue