mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-08-01 11:36:10 -04:00
VPN: Add method to retrieve wireguard private key
Signed-off-by: Malte Poll <mp@edgeless.systems>
This commit is contained in:
parent
e10a47f255
commit
0501d07f4a
3 changed files with 20 additions and 0 deletions
|
@ -54,6 +54,15 @@ func (w *Wireguard) Setup(privKey []byte) ([]byte, error) {
|
|||
return key[:], nil
|
||||
}
|
||||
|
||||
// GetPrivateKey returns the private key of the wireguard interface.
|
||||
func (w *Wireguard) GetPrivateKey() ([]byte, error) {
|
||||
device, err := w.client.Device(netInterface)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to retrieve wireguard private key from device %v: %w", netInterface, err)
|
||||
}
|
||||
return device.PrivateKey[:], nil
|
||||
}
|
||||
|
||||
func (w *Wireguard) GetPublicKey(privKey []byte) ([]byte, error) {
|
||||
key, err := wgtypes.NewKey(privKey)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue