[NetworkManager-openconnect] Allow key password to be set in config



commit 97b640caf7a5382e413ed6af48a64d86f4b093bd
Author: David Woodhouse <dwmw amazon co uk>
Date:   Sat Oct 13 07:04:43 2018 -0700

    Allow key password to be set in config
    
    Sometimes we want to just provision it with nmcli and not have to bother
    the user with it.

 auth-dialog/main.c           | 9 +++++++++
 shared/nm-service-defines.h  | 1 +
 src/nm-openconnect-service.c | 1 +
 3 files changed, 11 insertions(+)
---
diff --git a/auth-dialog/main.c b/auth-dialog/main.c
index fe4efed..65b55e6 100644
--- a/auth-dialog/main.c
+++ b/auth-dialog/main.c
@@ -1026,6 +1026,9 @@ static int get_config (auth_ui_data *ui_data,
        char *sslkey, *cert;
        char *csd_wrapper;
        char *reported_os;
+#if OPENCONNECT_CHECK_VER(5,5)
+       char *key_pass;
+#endif
        char *pem_passphrase_fsid;
        char *cafile;
        char *token_mode;
@@ -1108,6 +1111,12 @@ static int get_config (auth_ui_data *ui_data,
        sslkey = g_hash_table_lookup (options, NM_OPENCONNECT_KEY_PRIVKEY);
        openconnect_set_client_cert (vpninfo, OC3DUP (cert), OC3DUP (sslkey));
 
+#if OPENCONNECT_CHECK_VER(5,5)
+       key_pass = g_hash_table_lookup (options,
+                                             NM_OPENCONNECT_KEY_KEY_PASS);
+       if (key_pass)
+               openconnect_set_key_password(vpninfo, key_pass);
+#endif
        pem_passphrase_fsid = g_hash_table_lookup (options,
                                                   NM_OPENCONNECT_KEY_PEM_PASSPHRASE_FSID);
        if (pem_passphrase_fsid && cert && !strcmp(pem_passphrase_fsid, "yes"))
diff --git a/shared/nm-service-defines.h b/shared/nm-service-defines.h
index 8918573..e598bcc 100644
--- a/shared/nm-service-defines.h
+++ b/shared/nm-service-defines.h
@@ -38,6 +38,7 @@
 #define NM_OPENCONNECT_KEY_USERCERT "usercert"
 #define NM_OPENCONNECT_KEY_CACERT "cacert"
 #define NM_OPENCONNECT_KEY_PRIVKEY "userkey"
+#define NM_OPENCONNECT_KEY_KEY_PASS "key_pass"
 #define NM_OPENCONNECT_KEY_MTU "mtu"
 #define NM_OPENCONNECT_KEY_PEM_PASSPHRASE_FSID "pem_passphrase_fsid"
 #define NM_OPENCONNECT_KEY_PREVENT_INVALID_CERT "prevent_invalid_cert"
diff --git a/src/nm-openconnect-service.c b/src/nm-openconnect-service.c
index f9ff755..293f28f 100644
--- a/src/nm-openconnect-service.c
+++ b/src/nm-openconnect-service.c
@@ -84,6 +84,7 @@ static const ValidProperty valid_properties[] = {
        { NM_OPENCONNECT_KEY_AUTHTYPE,    G_TYPE_STRING, 0, 0 },
        { NM_OPENCONNECT_KEY_USERCERT,    G_TYPE_STRING, 0, 0 },
        { NM_OPENCONNECT_KEY_PRIVKEY,     G_TYPE_STRING, 0, 0 },
+       { NM_OPENCONNECT_KEY_KEY_PASS,    G_TYPE_STRING, 0, 0 },
        { NM_OPENCONNECT_KEY_MTU,         G_TYPE_STRING, 0, 0 },
        { NM_OPENCONNECT_KEY_PEM_PASSPHRASE_FSID, G_TYPE_BOOLEAN, 0, 0 },
        { NM_OPENCONNECT_KEY_PREVENT_INVALID_CERT, G_TYPE_BOOLEAN, 0, 0 },


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]