set_preshared_key


Description:

public bool set_preshared_key (string? preshared_key, bool accept_invalid)

Reset the preshared key.

Note that if the preshared key is valid, it will be normalized (which may or may not modify the set value).

Note that the preshared-key is a secret and consequently has corresponding preshared-key-flags property. This is so that secrets can be optional and requested on demand from a secret-agent. Also, an invalid preshared-key may optionally cause is_valid to fail or it may be accepted.

It is a bug trying to modify a sealed WireGuardPeer instance.

Parameters:

this

the unsealed WireGuardPeer instance

preshared_key

the new preshared key or null to clear the preshared key.

accept_invalid

whether to allow setting the key to an invalid value. If false, this is unchanged if the key is invalid and if false is returned.

Returns:

true if the preshared-key is valid, otherwise false. null is considered a valid value. If the key is invalid, it depends on accept_invalid whether the previous value was reset.