set_private_key


Description:

public bool set_private_key (string key_path, string password, Setting8021xCKScheme scheme, Setting8021xCKFormat out_format) throws Error

Private keys are used to authenticate the connecting client to the network when EAP-TLS is used as either the "phase 1" or "phase 2" 802.1x authentication method.

This function reads a private key from disk and sets the NMSetting8021x:private-key property with the private key file data if using the BLOB scheme, or with the path to the private key file if using the PATH scheme.

If password is given, this function attempts to decrypt the private key to verify that password is correct, and if it is, updates the private_key_password property with the given password. If the decryption is unsuccessful, false is returned, error is set, and no internal data is changed. If no password is given, the private key is assumed to be valid, no decryption is performed, and the password may be set at a later time.

WARNING: the private key property is not a "secret" property, and thus unencrypted private key data using the BLOB scheme may be readable by unprivileged users. Private keys should always be encrypted with a private key password to prevent unauthorized access to unencrypted private key data.

Parameters:

this

the Setting8021x

key_path

when scheme is set to either PATH or BLOB, pass the path of the private key file (PEM, DER, or PKCS#12 format). The path must be UTF-8 encoded; use to_utf8 to convert if needed. Passing null with any scheme clears the private key.

password

password used to decrypt the private key, or null if the password is unknown. If the password is given but fails to decrypt the private key, an error is returned.

scheme

desired storage scheme for the private key

out_format

on successful return, the type of the private key added

Returns:

true if the operation succeeded, false if it was unsuccessful