Add new function which returns the NSS 3.4 style nickname directly from a

NSSCertificate structure.


git-svn-id: svn://10.0.0.236/trunk@124032 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
relyea%netscape.com
2002-06-25 22:33:37 +00:00
parent bf14218920
commit ca4e1df93c
2 changed files with 47 additions and 2 deletions

View File

@@ -32,7 +32,7 @@
*/
#ifdef DEBUG
static const char CVS_ID[] = "@(#) $RCSfile: pki3hack.c,v $ $Revision: 1.56 $ $Date: 2002-06-24 22:36:59 $ $Name: not supported by cvs2svn $";
static const char CVS_ID[] = "@(#) $RCSfile: pki3hack.c,v $ $Revision: 1.57 $ $Date: 2002-06-25 22:33:37 $ $Name: not supported by cvs2svn $";
#endif /* DEBUG */
/*
@@ -547,6 +547,48 @@ get_cert_instance(NSSCertificate *c)
return instance;
}
char *
STAN_GetCERTCertificateName(NSSCertificate *c)
{
nssCryptokiInstance *instance = get_cert_instance(c);
NSSCryptoContext *context = c->object.cryptoContext;
PRStatus nssrv;
int nicklen, tokenlen, len;
NSSUTF8 *tokenName = NULL;
NSSUTF8 *stanNick = NULL;
char *nickname = NULL;
char *nick;
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)) {
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;
nickname = PORT_Alloc(len);
nick = nickname;
if (tokenName) {
memcpy(nick, tokenName, tokenlen-1);
nick += tokenlen-1;
*nick++ = ':';
}
memcpy(nick, stanNick, nicklen-1);
nickname[len-1] = '\0';
}
return nickname;
}
static void
fill_CERTCertificateFields(NSSCertificate *c, CERTCertificate *cc, PRBool forced)
{

View File

@@ -35,7 +35,7 @@
#define PKINSS3HACK_H
#ifdef DEBUG
static const char PKINSS3HACK_CVS_ID[] = "@(#) $RCSfile: pki3hack.h,v $ $Revision: 1.11 $ $Date: 2002-04-18 17:30:03 $ $Name: not supported by cvs2svn $";
static const char PKINSS3HACK_CVS_ID[] = "@(#) $RCSfile: pki3hack.h,v $ $Revision: 1.12 $ $Date: 2002-06-25 22:33:37 $ $Name: not supported by cvs2svn $";
#endif /* DEBUG */
#ifndef NSSDEVT_H
@@ -106,6 +106,9 @@ NSS_EXTERN PRStatus
nssPKIX509_GetIssuerAndSerialFromDER(NSSDER *der, NSSArena *arena,
NSSDER *issuer, NSSDER *serial);
NSS_EXTERN char *
STAN_GetCERTCertificateName(NSSCertificate *c);
/* exposing this */
NSS_EXTERN NSSCertificate *
NSSCertificate_Create