]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Added gnutls_certificate_get_crt_raw() to return the raw certificate as present in...
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Sat, 19 Oct 2013 07:33:14 +0000 (09:33 +0200)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Sat, 19 Oct 2013 07:33:14 +0000 (09:33 +0200)
NEWS
lib/gnutls_cert.c
lib/includes/gnutls/gnutls.h.in

diff --git a/NEWS b/NEWS
index 805415629269132111f64424378bf28512dbe7fb..22e2745309fc5b6791b39710367f4e2544ad9298 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -15,7 +15,7 @@ See the end for copying conditions.
 --inline-commands-prefix and --inline-commands options. Patch by Raj Raman.    
 
 ** API and ABI modifications:
-No changes since last version.
+gnutls_certificate_get_crt_raw: Added
 
 
 * Version 3.2.4 (released 2013-08-31)
index 3697836af014e4c6dceba55f340329c8db445089..285d5dffbca34a76aab140feaaccd75fb0949f8e 100644 (file)
@@ -119,6 +119,42 @@ gnutls_certificate_get_issuer (gnutls_certificate_credentials_t sc,
   return gnutls_x509_trust_list_get_issuer(sc->tlist, cert, issuer, flags);
 }
 
+/**
+ * gnutls_certificate_get_crt_raw:
+ * @sc: is a #gnutls_certificate_credentials_t structure.
+ * @idx1: the index of the certificate if multiple are present
+ * @idx2: the index in the certificate list. Zero gives the server's certificate.
+ * @cert: Will hold the DER encoded certificate.
+ *
+ * This function will return the DER encoded certificate of the
+ * server or any other certificate on its certificate chain (based on @idx2).
+ * The returned data should be treated as constant and only accessible during the lifetime
+ * of @sc.
+ *
+ * Returns: On success, %GNUTLS_E_SUCCESS (0) is returned, otherwise a
+ *   negative error value. In case the indexes are out of bounds %GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE
+ *   is returned.
+ *
+ * Since: 3.2.5
+ **/
+int
+gnutls_certificate_get_crt_raw (gnutls_certificate_credentials_t sc, 
+  unsigned idx1,
+  unsigned idx2,
+  gnutls_datum_t * cert)
+{
+  if (idx1 >= sc->ncerts)
+    return gnutls_assert_val(GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE);
+
+  if (idx2 >= sc->certs[idx1].cert_list_length)
+    return gnutls_assert_val(GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE);
+
+  cert->data = sc->certs[idx1].cert_list[idx2].cert.data;
+  cert->size = sc->certs[idx1].cert_list[idx2].cert.size;
+
+  return 0;
+}
+
 /**
  * gnutls_certificate_free_ca_names:
  * @sc: is a #gnutls_certificate_credentials_t structure.
index 25fb7fdc2d6594aaa6565f6ddaec0467a29a55e5..6c56879353f8946102e57d5349002f640dd3592b 100644 (file)
@@ -1297,6 +1297,9 @@ gnutls_ecc_curve_t gnutls_ecc_curve_get(gnutls_session_t session);
   int
     gnutls_certificate_get_issuer (gnutls_certificate_credentials_t sc,
     gnutls_x509_crt_t cert, gnutls_x509_crt_t* issuer, unsigned int flags);
+    
+  int gnutls_certificate_get_crt_raw (gnutls_certificate_credentials_t sc, unsigned idx1,
+    unsigned idx2, gnutls_datum_t * cert);
 
   void gnutls_certificate_free_keys (gnutls_certificate_credentials_t sc);
   void gnutls_certificate_free_cas (gnutls_certificate_credentials_t sc);