[network-manager-openvpn] import: fix base64 encoded inline <pkcs12> blobs
- From: Thomas Haller <thaller src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-openvpn] import: fix base64 encoded inline <pkcs12> blobs
- Date: Thu, 23 Mar 2017 09:20:34 +0000 (UTC)
commit f6c00d1e23cd5298dcf7e4e03f4d7543b4978c52
Author: Thomas Haller <thaller redhat com>
Date: Tue Mar 21 14:29:22 2017 +0100
import: fix base64 encoded inline <pkcs12> blobs
pkcs12 inline certificates are base64 encoded. Before writing
them to file they must be decoded.
https://bugzilla.gnome.org/show_bug.cgi?id=780251
properties/import-export.c | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/properties/import-export.c b/properties/import-export.c
index 7b42e0b..54ff342 100644
--- a/properties/import-export.c
+++ b/properties/import-export.c
@@ -1387,6 +1387,7 @@ do_import (const char *path, const char *contents, gsize contents_len, GError **
gs_free char *end_token = NULL;
gsize end_token_len;
gsize my_contents_cur_line = contents_cur_line;
+ gboolean is_base64 = FALSE;
char *f_path;
const char *key;
gboolean can_have_direction = FALSE;
@@ -1399,9 +1400,10 @@ do_import (const char *path, const char *contents, gsize contents_len, GError **
key = NM_OPENVPN_KEY_CERT;
else if (nm_streq (token, INLINE_BLOB_KEY))
key = NM_OPENVPN_KEY_KEY;
- else if (nm_streq (token, INLINE_BLOB_PKCS12))
+ else if (nm_streq (token, INLINE_BLOB_PKCS12)) {
+ is_base64 = TRUE;
key = NULL;
- else if (nm_streq (token, INLINE_BLOB_TLS_AUTH)) {
+ } else if (nm_streq (token, INLINE_BLOB_TLS_AUTH)) {
key = NM_OPENVPN_KEY_TA;
can_have_direction = TRUE;
} else if (nm_streq (token, INLINE_BLOB_SECRET)) {
@@ -1442,6 +1444,15 @@ do_import (const char *path, const char *contents, gsize contents_len, GError **
goto handle_line_error;
}
+ if (is_base64) {
+ gs_free guint8 *d = NULL;
+ gsize l;
+
+ d = g_base64_decode (blob_data->str, &l);
+ g_string_truncate (blob_data, 0);
+ g_string_append_len (blob_data, (const char *) d, l);
+ }
+
/* the latest cert wins... */
for (sl_iter = inline_blobs; sl_iter; sl_iter = sl_iter->next) {
InlineBlobData *d = sl_iter->data;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]