wireguard: make KeyPairs solid
Signed-off-by: Alejandro Mery <amery@jpi.io>
This commit is contained in:
@@ -169,15 +169,13 @@ func (kp *KeyPair) Validate() error {
|
||||
}
|
||||
|
||||
// NewKeyPair creates a new KeyPair for Wireguard
|
||||
func NewKeyPair() (*KeyPair, error) {
|
||||
key, err := NewPrivateKey()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
func NewKeyPair() (KeyPair, error) {
|
||||
var out KeyPair
|
||||
|
||||
out := &KeyPair{
|
||||
PrivateKey: key,
|
||||
PublicKey: key.Public(),
|
||||
key, err := NewPrivateKey()
|
||||
if err == nil {
|
||||
out.PrivateKey = key
|
||||
out.PublicKey = key.Public()
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user