[PATCH proxmox 1/2] wireguard: skip serializing preshared_key if unset

Stefan Hanreich
2026-02-19T14:55:53Z

Otherwise the generated WireGuard configuration is invalid, because it
contains a line 'PresharedKey=', which trips up wg(8). Avoid this by
skipping serialization for unset preshared keys.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
proxmox-wireguard/src/lib.rs | 1 +
1 file changed, 1 insertion(+)

diff --git a/proxmox-wireguard/src/lib.rs b/proxmox-wireguard/src/lib.rs
index 593713d8..41a2922d 100644
--- a/proxmox-wireguard/src/lib.rs
+++ b/proxmox-wireguard/src/lib.rs
@@ -155,6 +155,7 @@ pub struct WireGuardPeer {
/// Additional key preshared between two peers. Adds an additional layer of symmetric-key
/// cryptography to be mixed into the already existing public-key cryptography, for
/// post-quantum resistance.
+ #[serde(skip_serializing_if = "Option::is_none")]
pub preshared_key: Option<PresharedKey>,
/// List of IPv4/v6 CIDRs from which incoming traffic for this peer is allowed and to which
/// outgoing traffic for this peer is directed. The catch-all 0.0.0.0/0 may be specified for
--
2.47.3