Bug 251594 – Certificate from PKCS#12 file with colon in friendlyName not
authornelson%bolyard.com
Sat, 14 Jul 2007 06:01:03 +0000
changeset 7936 92a44f1c87b4ed83f5f23c373856fd3e115e8a58
parent 7935 12b3ef9875f197e3c9def2f500112352ef8a5636
child 7937 c0848af4cfb58484dbb0abada487e17a5c5690b1
push idunknown
push userunknown
push dateunknown
bugs251594
Bug 251594 – Certificate from PKCS#12 file with colon in friendlyName not selectable for signing/encryption. r=neil.williams
security/nss/lib/pki/pki3hack.c
--- a/security/nss/lib/pki/pki3hack.c
+++ b/security/nss/lib/pki/pki3hack.c
@@ -672,17 +672,18 @@ STAN_GetCERTCertificateNameForInstance (
 
     if (instance) {
 	stanNick = instance->label;
     } else if (context) {
 	stanNick = c->object.tempName;
     }
     if (stanNick) {
 	/* fill other fields needed by NSS3 functions using CERTCertificate */
-	if (instance && !PK11_IsInternal(instance->token->pk11slot)) {
+	if (instance && (!PK11_IsInternal(instance->token->pk11slot) || 
+	                 PORT_Strchr(stanNick, ':') != NULL) ) {
 	    tokenName = nssToken_GetName(instance->token);
 	    tokenlen = nssUTF8_Size(tokenName, &nssrv);
 	} else {
 	/* don't use token name for internal slot; 3.3 didn't */
 	    tokenlen = 0;
 	}
 	nicklen = nssUTF8_Size(stanNick, &nssrv);
 	len = tokenlen + nicklen;
@@ -736,17 +737,19 @@ fill_CERTCertificateFields(NSSCertificat
 	stanNick = c->object.tempName;
     }
     /* fill other fields needed by NSS3 functions using CERTCertificate */
     if ((!cc->nickname && stanNick) || forced) {
 	PRStatus nssrv;
 	int nicklen, tokenlen, len;
 	NSSUTF8 *tokenName = NULL;
 	char *nick;
-	if (instance && !PK11_IsInternal(instance->token->pk11slot)) {
+	if (instance && 
+	     (!PK11_IsInternal(instance->token->pk11slot) || 
+	      (stanNick && PORT_Strchr(stanNick, ':') != NULL))) {
 	    tokenName = nssToken_GetName(instance->token);
 	    tokenlen = nssUTF8_Size(tokenName, &nssrv);
 	} else {
 	    /* don't use token name for internal slot; 3.3 didn't */
 	    tokenlen = 0;
 	}
 	if (stanNick) {
 	    nicklen = nssUTF8_Size(stanNick, &nssrv);