]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Corrected bug which prevented gnutls_certificate_get_ours() from working.
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Fri, 4 Oct 2002 19:09:59 +0000 (19:09 +0000)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Fri, 4 Oct 2002 19:09:59 +0000 (19:09 +0000)
Added gnutls_certificate_get_our_issuer() function.

NEWS
doc/TODO
lib/gnutls_state.c
lib/gnutls_ui.c
lib/gnutls_ui.h

diff --git a/NEWS b/NEWS
index 4d75c6d17d64e71b7c5a89ff9728c967da713d0d..a57dc984f872bb77d9435336d6b6be45e4844e85 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,8 @@
 Version 0.5.9
 - Added gnutls_x509_extract_key_pk_algorithm() function which extracts
   the private key type.
+- Corrected some code which worked fine in gcc 3.2, but not with any
+  other compiler.
 
 Version 0.5.8 (25/09/2002)
 - Updated documentation.
index 7d4c3af96de225721e42121ac370d0e77c298e2a..c40dd5d63f78017f8459be34583da720c19d5689 100644 (file)
--- a/doc/TODO
+++ b/doc/TODO
@@ -4,7 +4,7 @@ in order to avoid having people working on the same thing.
 
 Current list:
 + Add ability to read PKCS-12 structures (certificate and private key)
-* Add functions to parse DER encoded private keys
+* Add more functions to parse DER encoded private keys
 * Add support for the certificate authenticated SRP cipher suites
 * Add option to read the SRP parameters using a callback (server side)
 * Add functions to generate SRP parameters and SRP verifiers
index 2ad6449fadad158d316da3115bb357cf88ee7d2f..e26780baec5716c6d56ead6d5833d8d9429d4e62 100644 (file)
@@ -125,7 +125,6 @@ void _gnutls_handshake_internal_state_clear( gnutls_session session) {
        session->internals.extensions_sent_size = 0;
 
        /* by default no selected certificate */
-       session->internals.selected_cert_index = -1;
        session->internals.proposed_record_size = DEFAULT_MAX_RECORD_SIZE;
        session->internals.adv_version_major = 0;
        session->internals.adv_version_minor = 0;
index 5779268e56de362440f54b3fd186efc095ff4ad6..98b7a5793f7077419e4a9277039740a04e926967 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *      Copyright (C) 2001 Nikos Mavroyanopoulos
+ *      Copyright (C) 2001,2002 Nikos Mavroyanopoulos
  *
  * This file is part of GNUTLS.
  *
@@ -181,7 +181,7 @@ int gnutls_dh_get_peers_public_bits(gnutls_session session)
   * gnutls_certificate_get_ours - This function returns the raw certificate sent in the last handshake
   * @session: is a gnutls session
   *
-  * This function will return the raw certificate list as sent to the peer,
+  * This function will return the certificate as sent to the peer,
   * in the last handshake. These certificates are in raw format. 
   * In X.509 this is a certificate list. In OpenPGP this is a single
   * certificate.
@@ -202,9 +202,46 @@ const gnutls_datum *gnutls_certificate_get_ours(gnutls_session session)
        }
 
        index = session->internals.selected_cert_index;
-       if (index < 0) return NULL; /* no certificate */
+       if (index < 0) {
+          gnutls_assert();
+          return NULL; /* no certificate */
+       }
        
-       return &cred->cert_list[index]->raw;
+       return &cred->cert_list[index][0].raw;
+}
+
+/**
+  * gnutls_certificate_get_our_issuer - This function returns the raw certificate sent in the last handshake
+  * @session: is a gnutls session
+  *
+  * This function will return the raw certificate of our issuer as sent to the peer,
+  * in the last handshake. This certificate is in raw format. 
+  * This has no meaning for OpenPGP keys.
+  * Returns NULL in case of an error, or if no certificate was found.
+  *
+  **/
+const gnutls_datum *gnutls_certificate_get_our_issuer(gnutls_session session)
+{
+       const gnutls_certificate_credentials cred;
+       int index;
+
+       CHECK_AUTH(GNUTLS_CRD_CERTIFICATE, NULL);
+
+       cred = _gnutls_get_cred(session->gnutls_key, GNUTLS_CRD_CERTIFICATE, NULL);
+       if (cred == NULL) {
+               gnutls_assert();
+               return NULL;
+       }
+
+       index = session->internals.selected_cert_index;
+       if (index < 0) {
+          gnutls_assert();
+          return NULL; /* no certificate */
+       }
+
+       if (cred->cert_list_length[index]-1 > 0)
+          return &cred->cert_list[index][cred->cert_list_length[index]-1].raw;
+       else return NULL;
 }
 
 /**
index 2a9cb4a4c245d9e216cec48c4d6e5b8821d5aaed..7bb997d7896d60fce2bbcc4c23099eedfcea9e9f 100644 (file)
@@ -100,6 +100,7 @@ int gnutls_x509_verify_certificate( const gnutls_datum* cert_list, int cert_list
 /* get data from the session */
 const gnutls_datum* gnutls_certificate_get_peers( gnutls_session, int* list_size);
 const gnutls_datum *gnutls_certificate_get_ours( gnutls_session session);
+const gnutls_datum *gnutls_certificate_get_our_issuer(gnutls_session session);
 
 time_t gnutls_certificate_activation_time_peers(gnutls_session session);
 time_t gnutls_certificate_expiration_time_peers(gnutls_session session);