pidgin: 3d32666b: Add NSS support for getting DER data.

qulogic at pidgin.im qulogic at pidgin.im
Thu Dec 22 21:25:47 EST 2011


----------------------------------------------------------------------
Revision: 3d32666bcc77cb7ef618be30d7de24663ae04089
Parent:   64235fd9a228e343ce46d7f492ad8128df7a638e
Author:   qulogic at pidgin.im
Date:     12/22/11 20:52:16
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/3d32666bcc77cb7ef618be30d7de24663ae04089

Changelog: 

Add NSS support for getting DER data.

Changes against parent 64235fd9a228e343ce46d7f492ad8128df7a638e

  patched  libpurple/plugins/ssl/ssl-nss.c

-------------- next part --------------
============================================================
--- libpurple/plugins/ssl/ssl-nss.c	124c474174cbde7da43e375e4ffa1f47950ab95b
+++ libpurple/plugins/ssl/ssl-nss.c	e7a5c12e7b2e9b258b2210c47774f507764dc5e7
@@ -930,6 +930,29 @@ x509_times (PurpleCertificate *crt, time
 	return TRUE;
 }
 
+static GByteArray *
+x509_get_der_data(PurpleCertificate *crt)
+{
+	CERTCertificate *crt_dat;
+	SECItem *dercrt;
+	GByteArray *data;
+
+	crt_dat = X509_NSS_DATA(crt);
+	g_return_val_if_fail(crt_dat, NULL);
+
+	dercrt = SEC_ASN1EncodeItem(NULL, NULL, crt_dat,
+	                            SEC_ASN1_GET(SEC_SignedCertificateTemplate));
+	g_return_val_if_fail(dercrt != NULL, FALSE);
+
+	data = g_byte_array_sized_new(dercrt->len);
+	memcpy(data->data, dercrt->data, dercrt->len);
+	data->len = dercrt->len;
+
+	SECITEM_FreeItem(dercrt, PR_TRUE);
+
+	return data;
+}
+
 static PurpleCertificateScheme x509_nss = {
 	"x509",                          /* Scheme name */
 	N_("X.509 Certificates"),        /* User-visible scheme name */
@@ -945,9 +968,9 @@ static PurpleCertificateScheme x509_nss 
 	x509_check_name,                 /* Check subject name */
 	x509_times,                      /* Activation/Expiration time */
 	x509_importcerts_from_file,      /* Multiple certificate import function */
+	x509_get_der_data,               /* Binary DER data */
 
 	NULL,
-	NULL,
 	NULL
 };
 


More information about the Commits mailing list