]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Updated the openpgp key API.
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Fri, 3 Oct 2003 12:16:39 +0000 (12:16 +0000)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Fri, 3 Oct 2003 12:16:39 +0000 (12:16 +0000)
20 files changed:
NEWS
configure.in
doc/tex/Makefile.am
doc/tex/funcs.tex
includes/Makefile.am
includes/gnutls/openpgp.h
lib/x509/crl.c
lib/x509/crq.c
lib/x509/pkcs12.c
lib/x509/pkcs12_bag.c
lib/x509/pkcs7.c
lib/x509/privkey.c
lib/x509/x509.c
libextra/Makefile.am
libextra/gnutls_extra.c
libextra/openpgp/Makefile.am
libextra/openpgp/gnutls_openpgp.h
libextra/openpgp/openpgp.c
libextra/openpgp/openpgp.h
src/common.c

diff --git a/NEWS b/NEWS
index c6ce8e4dc6fab090484067902195b6976c618c49..c4326304928ef09b4358ce123f0ef5b47a13c47b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,6 @@
+Version 0.9.90
+- Updated the openpgp key API.
+
 Version 0.9.8 (02/10/2003)
 - Updated the SRP implementation to follow the latest draft
   (draft-ietf-tls-srp-05).
index e822d8f649bde8cfd8f3088e56c4d5f2d59772ce..342ced7aefea5b60e4e2a1f8a652369740510847 100644 (file)
@@ -12,7 +12,7 @@ AC_DEFINE_UNQUOTED(T_OS, "$target_os", [OS name])
 dnl Gnutls Version
 GNUTLS_MAJOR_VERSION=0
 GNUTLS_MINOR_VERSION=9
-GNUTLS_MICRO_VERSION=8
+GNUTLS_MICRO_VERSION=90
 GNUTLS_VERSION=$GNUTLS_MAJOR_VERSION.$GNUTLS_MINOR_VERSION.$GNUTLS_MICRO_VERSION
 
 AC_DEFINE_UNQUOTED(GNUTLS_VERSION, "$GNUTLS_VERSION", [version of gnutls])
index c9aaa9cfe471e77182bdbb67894357252eb5100f..e9890e5b683cc20aef4252eb48b4a2e65bb50633 100644 (file)
@@ -11,6 +11,7 @@ EXAMPLE_OBJECTS = ex-alert.tex ex-client-srp.tex ex-serv-export.tex \
        ex-crq.tex ex-session-info.tex ex-pkcs12.tex
 
 TEX_OBJECTS = gnutls.tex ../../lib/gnutls-api.tex fdl.tex ../../lib/x509/x509-api.tex \
+       ../../libextra/openpgp/pgp-api.tex \
        macros.tex cover.tex ciphersuites.tex handshake.tex translayer.tex \
        auth.tex ciphers.tex errors.tex layers.tex alert.tex record.tex \
        funcs.tex examples.tex ../../libextra/gnutls-extra-api.tex \
@@ -30,6 +31,9 @@ build_api_lib:
 build_api_x509:
        cd ../../lib/x509 && make x509-api.tex
 
+build_api_pgp:
+       cd ../../libextra/openpgp && make pgp-api.tex
+
 build_api_extra:
        cd ../../libextra && make gnutls-extra-api.tex
 
@@ -45,7 +49,10 @@ gnutls-extra-api.tex: ../../libextra/gnutls-extra-api.tex
 x509-api.tex: ../../lib/x509/x509-api.tex
        -../scripts/sort1.pl < ../../lib/x509/x509-api.tex > x509-api.tex
 
-DOC_OBJECTS = x509-api.tex gnutls-api.tex gnutls-extra-api.tex error_codes.tex
+pgp-api.tex: ../../libextra/openpgp/pgp-api.tex
+       -../scripts/sort1.pl < ../../libextra/openpgp/pgp-api.tex > pgp-api.tex
+
+DOC_OBJECTS = pgp-api.tex x509-api.tex gnutls-api.tex gnutls-extra-api.tex error_codes.tex
 
 gnutls.ps: build_api_lib build_api_x509 build_api_extra $(TEX_OBJECTS) $(DOC_OBJECTS)
        -latex gnutls.tex
index 04ab42e2c8d7f7c9ca6cfa3643d3199e03a1bb30..ba99204130d6388bcb6cdfcbac76ac570c08b7d6 100644 (file)
@@ -23,5 +23,12 @@ These functions are only available in the GPL version of the
 library called ``gnutls-extra''. The prototypes for this library lie
 in ``gnutls/extra.h''.
 
+\section{\gnutls{} OpenPGP key handling\index{Function reference!for OpenPGP keys}}
+\label{sec:x509api}
+The following functions are to be used for OpenPGP certificate handling.
+Their prototypes lie in ``gnutls/openpgp.h''.
+
+\input{pgp-api}
+
 \input{gnutls-extra-api}
 
index a363f404437aa7195a62bdc6e43819f101f2d012..d75f0fed065751ecf0efdfad22a285a15d6a247e 100644 (file)
@@ -1,7 +1,8 @@
 ## Process this file with automake to produce Makefile.in
 
 nobase_include_HEADERS = gnutls/extra.h gnutls/openssl.h gnutls/gnutls.h \
-       gnutls/compat4.h gnutls/x509.h gnutls/compat8.h gnutls/pkcs12.h
+       gnutls/compat4.h gnutls/x509.h gnutls/compat8.h gnutls/pkcs12.h \
+       gnutls/openpgp.h
 
 SUBDIRS = gnutls
 
index 6fce2e5b05d964cb14616281f25d4b4aef6a72f9..a2bef1483e38dd0fdf04bd5b0b2f30e7b35c58ca 100644 (file)
@@ -32,7 +32,8 @@ extern "C" {
 
 #include <gnutls/gnutls.h>
 
-struct gnutls_openpgp_key; /* object to hold (parsed) openpgp keys */
+struct gnutls_openpgp_key_int; /* object to hold (parsed) openpgp keys */
+typedef struct gnutls_openpgp_key_int* gnutls_openpgp_key;
 
 typedef enum gnutls_openpgp_key_fmt { GNUTLS_X509_FMT_RAW,
         GNUTLS_X509_FMT_BASE64 } gnutls_openpgp_key_fmt;
@@ -47,8 +48,7 @@ int gnutls_openpgp_key_get_fingerprint( gnutls_openpgp_key key,
        char* result, size_t* result_size);
        
 int gnutls_openpgp_key_get_name( gnutls_openpgp_key key,
-                                 int idx,
-                                 char *buf, size_t *sizeof_buf);
+       int idx, char *buf, size_t *sizeof_buf);
 
 int gnutls_openpgp_key_get_pk_algorithm(gnutls_openpgp_key key,
                                             int *r_bits);
@@ -62,12 +62,13 @@ int gnutls_openpgp_key_get_id( gnutls_openpgp_key key, unsigned char keyid[8]);
 
 int gnutls_openpgp_key_check_hostname( gnutls_openpgp_key key, const char *hostname);
 
-int gnutls_openpgp_key_to_xml( gnutls_openpgp_key key key, gnutls_datum *xmlkey,
+int gnutls_openpgp_key_to_xml( gnutls_openpgp_key key, gnutls_datum *xmlkey,
        int ext);
 
 /* Keyring stuff.
  */
-struct gnutls_openpgp_keyring;
+struct gnutls_openpgp_keyring_int; /* object to hold (parsed) openpgp keyrings */
+typedef struct gnutls_openpgp_keyring_int* gnutls_openpgp_keyring;
 
 int gnutls_openpgp_keyring_init( gnutls_openpgp_keyring* ring);
 void gnutls_openpgp_keyring_deinit(gnutls_openpgp_keyring ring);
@@ -77,7 +78,8 @@ int gnutls_openpgp_keyring_import(gnutls_openpgp_keyring ring,
 
 /* Trustdb functions.
  */
-struct gnutls_openpgp_trustdb;
+struct gnutls_openpgp_trustdb_int; /* object to hold (parsed) openpgp trustdbs */
+typedef struct gnutls_openpgp_trustdb_int* gnutls_openpgp_trustdb;
 
 int gnutls_openpgp_trustdb_init( gnutls_openpgp_trustdb* db);
 void gnutls_openpgp_trustdb_deinit(gnutls_openpgp_trustdb db);
@@ -89,13 +91,13 @@ int gnutls_openpgp_trustdb_import(gnutls_openpgp_trustdb db,
 int gnutls_openpgp_key_verify_ring( 
        gnutls_openpgp_key key, 
        gnutls_openpgp_keyring ring,
-       unsigned int flags /* if not used reserved for future use,
+       unsigned int flags,
        unsigned int * verify /* the output of the verification */);
 
 int gnutls_openpgp_key_verify_trustdb( 
        gnutls_openpgp_key key, 
        gnutls_openpgp_trustdb db,
-       unsigned int flags /* if not used reserved for future use,
+       unsigned int flags,
        unsigned int * verify /* the output of the verification */);
 
 
index c0e6c3f6704255d54cad6323c962934e1bcc5112..615a99004eb5e001a642eebb42c0b6fb7ba36e6a 100644 (file)
@@ -71,6 +71,8 @@ int gnutls_x509_crl_init(gnutls_x509_crl * crl)
   **/
 void gnutls_x509_crl_deinit(gnutls_x509_crl crl)
 {
+       if (!crl) return;
+
        if (crl->crl)
                asn1_delete_structure(&crl->crl);
        _gnutls_free_datum(&crl->signed_data);
index 0812594ca3f90fa7b7e7044f5be966c3f0d0c9ab..9a4a03edc1008174f86794dd9f56ca9bd350a3c3 100644 (file)
@@ -75,6 +75,8 @@ int gnutls_x509_crq_init(gnutls_x509_crq * crq)
   **/
 void gnutls_x509_crq_deinit(gnutls_x509_crq crq)
 {
+       if (!crq) return;
+
        if (crq->crq)
                asn1_delete_structure(&crq->crq);
 
index b53f2c03e8dd0201245d230ab3594c46f082c773..dfb709663dc820dbf1a0ba01de5a0bee349adf1a 100644 (file)
@@ -145,6 +145,8 @@ int gnutls_pkcs12_init(gnutls_pkcs12 * pkcs12)
   **/
 void gnutls_pkcs12_deinit(gnutls_pkcs12 pkcs12)
 {
+       if (!pkcs12) return;
+
        if (pkcs12->pkcs12)
                asn1_delete_structure(&pkcs12->pkcs12);
 
index 332fb52c52f3b2beca048ee1790e167b08414f6f..2193dd987cac6b85da7006649d4bf2b3edea7af8 100644 (file)
@@ -79,6 +79,8 @@ int i;
   **/
 void gnutls_pkcs12_bag_deinit(gnutls_pkcs12_bag bag)
 {
+       if (!bag) return;
+
        _pkcs12_bag_free_data( bag);
 
        gnutls_free(bag);
index b7ae363310f7293d8741db5b45c17ac4fa0cf6b6..9f9ad12cfba99362b85faaed2e14f452568b676d 100644 (file)
@@ -161,6 +161,8 @@ int gnutls_pkcs7_init(gnutls_pkcs7 * pkcs7)
   **/
 void gnutls_pkcs7_deinit(gnutls_pkcs7 pkcs7)
 {
+       if (!pkcs7) return;
+
        if (pkcs7->pkcs7)
                asn1_delete_structure(&pkcs7->pkcs7);
 
index ba989bf13f58b4f8049b625653905eae55c622c7..cdc2c755bf559d1ddd6f052b1954ec34dbe5ba16 100644 (file)
@@ -67,6 +67,8 @@ void gnutls_x509_privkey_deinit(gnutls_x509_privkey key)
 {
 int i;
 
+       if (!key) return;
+
        for (i = 0; i < key->params_size; i++) {
                _gnutls_mpi_release( &key->params[i]);
        }
index c0b7a6666bfacf76f5b9f00f760165af5e913192..f7fbe07ff9ae72e7757341c8d8389195d28c8f20 100644 (file)
@@ -123,6 +123,8 @@ gnutls_datum tmp;
   **/
 void gnutls_x509_crt_deinit(gnutls_x509_crt cert)
 {
+       if (!cert) return;
+
        if (cert->cert)
                asn1_delete_structure(&cert->cert);
        _gnutls_free_datum(&cert->signed_data);
index a0279ac02a72c941de5184ad67000f0e3d5f400b..175313cc09b8bc415090b70e213db4b18500c93d 100644 (file)
@@ -33,7 +33,7 @@ libgnutls_extra_la_SOURCES = $(COBJECTS_EXTRA)
 
 libgnutls_extra_la_LIBADD = $(LZO_OBJECTS) ../lib/libgnutls.la \
        openpgp/openpgp.lo openpgp/xml.lo openpgp/gnutls_openpgp.lo \
-       openpgp/extras.lo openpgp/verify.lo
+       openpgp/extras.lo openpgp/verify.lo openpgp/compat.lo
 
 EXTRA_libgnutls_extra_la_SOURCES = minilzo.c
 
index 5938e9ff927c7f36019ab3512154b28a636d036a..2e2c27c3a8394a24ea14763d4cad43e33d05e81b 100644 (file)
@@ -22,7 +22,7 @@
 #include <gnutls_errors.h>
 #include <gnutls_extensions.h>
 #include <ext_srp.h>
-#include <gnutls_openpgp.h>
+#include <openpgp/gnutls_openpgp.h>
 #include <gnutls_extra.h>
 #include <gnutls_algorithms.h>
 #include <minilzo.h>
@@ -151,12 +151,14 @@ extern OPENPGP_FINGERPRINT _E_gnutls_openpgp_fingerprint;
 extern OPENPGP_KEY_REQUEST _E_gnutls_openpgp_request_key;
 
 static void _gnutls_add_openpgp_functions(void) {
+#ifdef HAVE_LIBOPENCDK
        _E_gnutls_openpgp_verify_key = gnutls_openpgp_verify_key;
        _E_gnutls_openpgp_extract_key_expiration_time = gnutls_openpgp_extract_key_expiration_time;
        _E_gnutls_openpgp_extract_key_creation_time = gnutls_openpgp_extract_key_creation_time;
        _E_gnutls_openpgp_fingerprint = gnutls_openpgp_fingerprint;
        _E_gnutls_openpgp_request_key = _gnutls_openpgp_request_key;
        _E_gnutls_openpgp_cert2gnutls_cert = _gnutls_openpgp_cert2gnutls_cert;
+#endif
 }
 
 extern const char* gnutls_check_version( const char*);
index 787a84ae54f50ba85e678c76a24ae20c849528de..6c47b1835a4e1a78a095f5a29a64b2659fc650a8 100644 (file)
@@ -3,7 +3,7 @@ EXTRA_DIST = openpgp.h gnutls_openpgp.h
 
 noinst_LTLIBRARIES = libpgp.la
 
-COBJECTS = openpgp.c xml.c gnutls_openpgp.c verify.c extras.c
+COBJECTS = openpgp.c xml.c gnutls_openpgp.c verify.c extras.c compat.c
 
 libpgp_la_SOURCES = $(COBJECTS)
 
index e89708d10eb423da0128af28de3d73100414ab5c..7a60dfa1c41f06fc3eaa3216ded59e9bc935f7bd 100644 (file)
@@ -80,5 +80,14 @@ keybox_blob* kbx_read_blob( const gnutls_datum* keyring, size_t pos );
 cdk_keydb_hd_t kbx_to_keydb( keybox_blob *blob );
 void kbx_blob_release( keybox_blob *ctx );
 
+int gnutls_openpgp_verify_key(const char *trustdb,
+                         const gnutls_datum * keyring,
+                         const gnutls_datum * cert_list,
+                         int cert_list_length);
+int gnutls_openpgp_fingerprint(const gnutls_datum * cert,
+                          unsigned char *fpr, size_t * fprlen);
+time_t gnutls_openpgp_extract_key_creation_time(const gnutls_datum * cert);
+time_t gnutls_openpgp_extract_key_expiration_time(const gnutls_datum * cert);
+
 
 #endif /*GNUTLS_OPENPGP_H*/
index c24c8a14f91c508274cb014ec81ab1d854840e03..c30a3a10622376f279dd66991245820ca417f33f 100644 (file)
@@ -62,6 +62,8 @@ int gnutls_openpgp_key_init(gnutls_openpgp_key * key)
   **/
 void gnutls_openpgp_key_deinit(gnutls_openpgp_key key)
 {
+       if (!key) return;
+
        if (key->knode) {
                cdk_kbnode_release( key->knode);
                key->knode = NULL;
@@ -275,7 +277,7 @@ gnutls_openpgp_key_get_pk_algorithm( gnutls_openpgp_key key, int *r_bits)
  * Extract the version of the OpenPGP key.
  **/
 int
-gnutls_openpgp_extract_key_version( gnutls_openpgp_key key)
+gnutls_openpgp_key_get_version( gnutls_openpgp_key key)
 {
     CDK_PACKET *pkt;
     int version = 0;
@@ -298,7 +300,7 @@ gnutls_openpgp_extract_key_version( gnutls_openpgp_key key)
  * Returns the timestamp when the OpenPGP key was created.
  **/
 time_t
-gnutls_openpgp_extract_key_creation_time( gnutls_openpgp_key key)
+gnutls_openpgp_key_get_creation_time( gnutls_openpgp_key key)
 {
     CDK_PACKET *pkt;
     time_t timestamp = 0;
index b559522da724ded10db7ec6dcdb9fe4d0fd63451..e98ad18de81892a0490cee4a7e12ba29cf857a09 100644 (file)
@@ -28,6 +28,38 @@ int
 gnutls_openpgp_key_get_name( gnutls_openpgp_key key, 
        int idx,
         char *buf, size_t *sizeof_buf);
+int gnutls_openpgp_key_get_fingerprint( gnutls_openpgp_key key, 
+                            unsigned char *fpr, size_t *fprlen);
+int gnutls_openpgp_key_get_pk_algorithm( gnutls_openpgp_key key, int *r_bits);
+int gnutls_openpgp_key_get_version( gnutls_openpgp_key key);
+time_t gnutls_openpgp_key_get_creation_time( gnutls_openpgp_key key);
+time_t gnutls_openpgp_key_get_expiration_time( gnutls_openpgp_key key);
+int gnutls_openpgp_key_get_id( gnutls_openpgp_key key,
+                               unsigned char keyid[8]);
 
+int gnutls_openpgp_key_init(gnutls_openpgp_key * key);
+void gnutls_openpgp_key_deinit(gnutls_openpgp_key key);
+int gnutls_openpgp_key_import(gnutls_openpgp_key key, 
+       const gnutls_datum * data, gnutls_openpgp_key_fmt format);
+
+
+void gnutls_openpgp_keyring_deinit(gnutls_openpgp_keyring keyring);
+int gnutls_openpgp_keyring_init(gnutls_openpgp_keyring * keyring);
+int gnutls_openpgp_keyring_import(gnutls_openpgp_keyring keyring, 
+       const gnutls_datum * data,
+       gnutls_openpgp_key_fmt format);
+
+void gnutls_openpgp_trustdb_deinit(gnutls_openpgp_trustdb trustdb);
+int gnutls_openpgp_trustdb_init(gnutls_openpgp_trustdb * trustdb);
+int gnutls_openpgp_trustdb_import_file(gnutls_openpgp_trustdb trustdb, 
+       const char * file);
+
+int gnutls_openpgp_key_verify_ring( gnutls_openpgp_key key,
+                           gnutls_openpgp_keyring keyring,
+                           unsigned int flags, unsigned int *verify);
+
+int gnutls_openpgp_key_verify_trustdb( gnutls_openpgp_key key, 
+       gnutls_openpgp_trustdb trustdb,
+        unsigned int flags, unsigned int *verify);
 
 #endif
index 702136bd2a7f395d170ef21374ea2d4794554788..ecc9a9eeb4b2c9ad6b9ab24707a4034e9913da44 100644 (file)
@@ -4,6 +4,7 @@
 #include <gnutls/gnutls.h>
 #include <gnutls/extra.h>
 #include <gnutls/x509.h>
+#include <gnutls/openpgp.h>
 #include <time.h>
 #include <common.h>
 
@@ -12,8 +13,7 @@
 int xml = 0;
 
 #define PRINTX(x,y) if (y[0]!=0) printf(" #   %s %s\n", x, y)
-#define PRINT_PGP_NAME(X) PRINTX( "NAME:", X.name); \
-       PRINTX( "EMAIL:", X.email)
+#define PRINT_PGP_NAME(X) PRINTX( "NAME:", name)
 
 const char str_unknown[] = "(unknown)";
 
@@ -178,36 +178,67 @@ void print_x509_info(gnutls_session session, const char* hostname)
 
 }
 
-void print_openpgp_info(gnutls_session session)
+void print_openpgp_info(gnutls_session session, const char* hostname)
 {
 
-       gnutls_openpgp_name pgp_name;
        char digest[20];
-       int digest_size = sizeof(digest), i;
+       int digest_size = sizeof(digest), i, ret;
        char printable[120];
        char *print;
+       char name[256];
+       size_t name_len = sizeof(name);
+       gnutls_openpgp_key crt;
        const gnutls_datum *cert_list;
        int cert_list_size = 0;
-       time_t expiret = gnutls_certificate_expiration_time_peers(session);
-       time_t activet = gnutls_certificate_activation_time_peers(session);
-
+       time_t expiret;
+       time_t activet;
+       
        cert_list = gnutls_certificate_get_peers(session, &cert_list_size);
 
        if (cert_list_size > 0) {
                int algo, bits;
 
-#if 0
-               if (xml) {
-                       gnutls_datum res;
+               gnutls_openpgp_key_init(&crt);
+               ret =
+                   gnutls_openpgp_key_import(crt, &cert_list[0], 0);
+               if (ret < 0) {
+                       const char* str = gnutls_strerror(ret);
+                       if (str == NULL) str = str_unknown;
+                       fprintf(stderr, "Decoding error: %s\n", str);
+                       return;
+               }
+
+               if (hostname != NULL) { /* Check the hostname of the first certificate
+                            * if it matches the name of the host we
+                            * connected to.
+                            */
+                            if (gnutls_openpgp_key_check_hostname( crt, hostname)==0) {
+                               printf(" # The hostname in the key does NOT match '%s'.\n", hostname);
+                            } else {
+                               printf(" # The hostname in the key matches '%s'.\n", hostname);
+                            }
+               }
 
-                       gnutls_openpgp_key_to_xml(&cert_list[0], &res, 0);
-                       puts(res.data);
+               if (xml) {
+                       gnutls_datum xml_data;
 
-                       free(res.data);
+                       ret = gnutls_openpgp_key_to_xml( crt, &xml_data, 0);
+                       if (ret < 0) {
+                               const char* str = gnutls_strerror(ret);
+                               if (str == NULL) str = str_unknown;
+                               fprintf(stderr, "XML encoding error: %s\n",
+                                       str);
+                               return;
+                       }
+                       
+                       printf("%s", xml_data.data);
+                       gnutls_free( xml_data.data);
 
                        return;
                }
-#endif
+
+               activet = gnutls_openpgp_key_get_creation_time( crt);
+               expiret = gnutls_openpgp_key_get_expiration_time( crt);
 
                printf(" # Key was created at: %s", my_ctime(&activet));
                printf(" # Key expires: ");
@@ -216,8 +247,8 @@ void print_openpgp_info(gnutls_session session)
                else
                        printf("Never\n");
 
-               if (gnutls_openpgp_fingerprint
-                   (&cert_list[0], digest, &digest_size) >= 0) {
+               if (gnutls_openpgp_key_get_fingerprint(crt, digest, &digest_size) >= 0) 
+               {
                        print = printable;
                        for (i = 0; i < digest_size; i++) {
                                sprintf(print, "%.2x ",
@@ -226,12 +257,10 @@ void print_openpgp_info(gnutls_session session)
                        }
 
                        printf(" # PGP Key version: %d\n",
-                              gnutls_openpgp_extract_key_version
-                              (&cert_list[0]));
+                              gnutls_openpgp_key_get_version(crt));
 
                        algo =
-                           gnutls_openpgp_extract_key_pk_algorithm
-                           (&cert_list[0], &bits);
+                           gnutls_openpgp_key_get_pk_algorithm(crt, &bits);
 
                        printf(" # PGP Key public key algorithm: ");
 
@@ -247,14 +276,12 @@ void print_openpgp_info(gnutls_session session)
 
                        printf(" # PGP Key fingerprint: %s\n", printable);
 
-                       if (gnutls_openpgp_extract_key_name(&cert_list[0],
-                                                           0,
-                                                           &pgp_name) <
-                           0) {
+                       name_len = sizeof(name);
+                       if (gnutls_openpgp_key_get_name(crt, 0, name, &name_len) < 0) {
                                fprintf(stderr,
                                        "Could not extract name\n");
                        } else {
-                               PRINT_PGP_NAME(pgp_name);
+                               PRINT_PGP_NAME(name);
                        }
 
                }
@@ -386,7 +413,7 @@ void print_cert_info(gnutls_session session, const char* hostname)
                break;
        case GNUTLS_CRT_OPENPGP:
                printf("OpenPGP\n");
-               print_openpgp_info(session);
+               print_openpgp_info(session, hostname);
                break;
        }