summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2017-07-18 10:53:02 +0200
committerThomas Haller <thaller@redhat.com>2017-08-23 13:33:22 +0200
commitf78c1fe9e528a7cf2edd430a559e2fe5fd5525a7 (patch)
tree1af6bf11a17ac8c5d2a21e5868881ea61efc3b00
parent3721371ee8b9762725ddd163204fdaa086812b33 (diff)
downloadnetwork-manager-applet-f78c1fe9e528a7cf2edd430a559e2fe5fd5525a7.tar.gz
libnma: don't return empty passwords from certificate chooser
Return NULL if the user did not specify any password. Setting an empty password in the connection when it's not needed (e.g. for CA and client certificate) makes the connection invalid. Fixes: cfb753f6c907aa443307e48fb21eae0b2755bf22 https://bugzilla.redhat.com/show_bug.cgi?id=1469852
-rw-r--r--src/libnma/nma-pkcs11-cert-chooser.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/libnma/nma-pkcs11-cert-chooser.c b/src/libnma/nma-pkcs11-cert-chooser.c
index 852be2e1..1c033e93 100644
--- a/src/libnma/nma-pkcs11-cert-chooser.c
+++ b/src/libnma/nma-pkcs11-cert-chooser.c
@@ -48,9 +48,12 @@ static const gchar *
get_key_password (NMACertChooser *cert_chooser)
{
NMAPkcs11CertChooserPrivate *priv = NMA_PKCS11_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
+ const gchar *text;
g_return_val_if_fail (priv->key_password != NULL, NULL);
- return gtk_entry_get_text (GTK_ENTRY (priv->key_password));
+ text = gtk_entry_get_text (GTK_ENTRY (priv->key_password));
+
+ return text && text[0] ? text : NULL;
}
static void
@@ -87,9 +90,12 @@ static const gchar *
get_cert_password (NMACertChooser *cert_chooser)
{
NMAPkcs11CertChooserPrivate *priv = NMA_PKCS11_CERT_CHOOSER_GET_PRIVATE (cert_chooser);
+ const gchar *text;
g_return_val_if_fail (priv->cert_password != NULL, NULL);
- return gtk_entry_get_text (GTK_ENTRY (priv->cert_password));
+ text = gtk_entry_get_text (GTK_ENTRY (priv->cert_password));
+
+ return text && text[0] ? text : NULL;
}
static void