[glib-networking/wip/tingping/pkcs11] FIXES



commit 2beb4d0fe0c8d2715fec13ed39e1bbf69d98d9ea
Author: Patrick Griffis <tingping tingping se>
Date:   Fri Jun 7 12:59:40 2019 -0700

    FIXES

 tls/gnutls/gtlsdatabase-gnutls-pkcs11.c |  2 +-
 tools/dump-issuer-der-from-der.py       | 17 +++++++++++++++++
 tools/gtls-database-tool.c              |  4 +++-
 3 files changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/tls/gnutls/gtlsdatabase-gnutls-pkcs11.c b/tls/gnutls/gtlsdatabase-gnutls-pkcs11.c
index 6a647d3..876f8ca 100644
--- a/tls/gnutls/gtlsdatabase-gnutls-pkcs11.c
+++ b/tls/gnutls/gtlsdatabase-gnutls-pkcs11.c
@@ -1092,7 +1092,7 @@ g_tls_database_gnutls_pkcs11_initable_init (GInitable     *initable,
 
   g_return_val_if_fail (!self->modules, FALSE);
 
-  self->modules = p11_kit_modules_load (NULL, 0);
+  self->modules = p11_kit_modules_load_and_initialize (0);
   if (self->modules == NULL) {
     g_set_error_literal (error, G_PKCS11_ERROR, CKR_FUNCTION_FAILED, p11_kit_message ());
     return FALSE;
diff --git a/tools/dump-issuer-der-from-der.py b/tools/dump-issuer-der-from-der.py
new file mode 100755
index 0000000..bc8e951
--- /dev/null
+++ b/tools/dump-issuer-der-from-der.py
@@ -0,0 +1,17 @@
+#!/usr/bin/env python3
+
+import sys
+from textwrap import wrap
+
+import gi
+gi.require_version('Gcr', '3')
+from gi.repository import Gcr
+
+# Read in DER formatted file
+with open(sys.argv[1], 'rb') as cert_file:
+        cert_bytes = cert_file.read()
+
+cert = Gcr.SimpleCertificate.new(cert_bytes)
+issuer_bytes = cert.get_issuer_raw()
+
+print('\\x' + '\\x'.join(wrap(issuer_bytes.hex(), 2)))
\ No newline at end of file
diff --git a/tools/gtls-database-tool.c b/tools/gtls-database-tool.c
index 2683fc4..2c91e51 100644
--- a/tools/gtls-database-tool.c
+++ b/tools/gtls-database-tool.c
@@ -31,7 +31,9 @@ main (int argc, char const *argv[])
   g_autoptr(GTlsDatabase) pk_db = g_tls_backend_get_pkcs11_database (backend);
   g_autoptr(GError) error = NULL;
 
-  g_autoptr(GByteArray) issuer = g_byte_array_new_take ((guint8*)g_strdup("DC = com, DC = pivkey, CN = 
PIVKey Device Certificate Authority"), strlen("DC = com, DC = pivkey, CN = PIVKey Device Certificate 
Authority"));
+  const guchar issuer_str[] = 
"\x30\x7e\x31\x0b\x30\x09\x06\x03\x55\x04\x06\x13\x02\x55\x53\x31\x13\x30\x11\x06\x03\x55\x04\x08\x0c\x0a\x43\x61\x6c\x69\x66\x6f\x72\x6e\x69\x61\x31\x16\x30\x14\x06\x03\x55\x04\x07\x0c\x0d\x53\x61\x6e\x20\x46\x72\x61\x6e\x63\x69\x73\x63\x6f\x31\x0f\x30\x0d\x06\x03\x55\x04\x0a\x0c\x06\x42\x61\x64\x53\x53\x4c\x31\x31\x30\x2f\x06\x03\x55\x04\x03\x0c\x28\x42\x61\x64\x53\x53\x4c\x20\x43\x6c\x69\x65\x6e\x74\x20\x52\x6f\x6f\x74\x20\x43\x65\x72\x74\x69\x66\x69\x63\x61\x74\x65\x20\x41\x75\x74\x68\x6f\x72\x69\x74\x79";
+  g_autoptr(GByteArray) issuer = g_byte_array_new ();
+  g_byte_array_append (issuer, issuer_str, G_N_ELEMENTS (issuer_str) - 1);
 
   GList *certs = g_tls_database_lookup_certificates_issued_by (pk_db, issuer, NULL, 
G_TLS_DATABASE_LOOKUP_NONE, NULL, &error);
   g_message ("%p %p %p", pk_db, certs, error);


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