b=117148 S/MIME tool fails to find certificate while signing

r=javi sr=alecf
This commit is contained in:
kaie%netscape.com 2002-01-16 04:30:55 +00:00
parent 87002d36a7
commit 8dc27f323f
8 changed files with 30 additions and 17 deletions

View File

@ -403,7 +403,8 @@ nsNSSASN1Outliner::GetCellText(PRInt32 row, const PRUnichar *colID,
{
nsCOMPtr<nsIASN1Object> object;
_retval.SetCapacity(0);
char *col = NS_CONST_CAST(char *, NS_ConvertUCS2toUTF8(colID).get());
NS_ConvertUCS2toUTF8 aUtf8ColID(colID);
const char *col = aUtf8ColID.get();
nsresult rv = NS_OK;
if (strcmp(col, "certDataCol") == 0) {
rv = GetASN1ObjectAtIndex(row, mASN1Object,

View File

@ -403,7 +403,8 @@ nsNSSASN1Outliner::GetCellText(PRInt32 row, const PRUnichar *colID,
{
nsCOMPtr<nsIASN1Object> object;
_retval.SetCapacity(0);
char *col = NS_CONST_CAST(char *, NS_ConvertUCS2toUTF8(colID).get());
NS_ConvertUCS2toUTF8 aUtf8ColID(colID);
const char *col = aUtf8ColID.get();
nsresult rv = NS_OK;
if (strcmp(col, "certDataCol") == 0) {
rv = GetASN1ObjectAtIndex(row, mASN1Object,

View File

@ -470,7 +470,8 @@ nsCertOutliner::GetCellText(PRInt32 row, const PRUnichar *colID,
nsAString& _retval)
{
nsresult rv;
char *col = NS_CONST_CAST(char *, NS_ConvertUCS2toUTF8(colID).get());
NS_ConvertUCS2toUTF8 aUtf8ColID(colID);
const char *col = aUtf8ColID.get();
outlinerArrayEl *el = GetThreadDescAtIndex(row);
if (el != nsnull) {
if (strcmp(col, "certcol") == 0)

View File

@ -470,7 +470,8 @@ nsCertOutliner::GetCellText(PRInt32 row, const PRUnichar *colID,
nsAString& _retval)
{
nsresult rv;
char *col = NS_CONST_CAST(char *, NS_ConvertUCS2toUTF8(colID).get());
NS_ConvertUCS2toUTF8 aUtf8ColID(colID);
const char *col = aUtf8ColID.get();
outlinerArrayEl *el = GetThreadDescAtIndex(row);
if (el != nsnull) {
if (strcmp(col, "certcol") == 0)

View File

@ -2563,7 +2563,8 @@ nsNSSCertificateDB::GetCertByNickname(nsIPK11Token *aToken,
{
CERTCertificate *cert = NULL;
char *asciiname = NULL;
asciiname = NS_CONST_CAST(char*, NS_ConvertUCS2toUTF8(nickname).get());
NS_ConvertUCS2toUTF8 aUtf8Nickname(nickname);
asciiname = NS_CONST_CAST(char*, aUtf8Nickname.get());
PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("Getting \"%s\"\n", asciiname));
#if 0
// what it should be, but for now...
@ -4303,7 +4304,8 @@ nsNSSCertificateDB::GetEmailEncryptionCert(const PRUnichar* aNickname, nsIX509Ce
nsCOMPtr<nsIInterfaceRequestor> ctx = new PipUIContext();
nsNSSCertificate *nssCert = nsnull;
char *asciiname = NULL;
asciiname = NS_CONST_CAST(char*, NS_ConvertUCS2toUTF8(aNickname).get());
NS_ConvertUCS2toUTF8 aUtf8Nickname(aNickname);
asciiname = NS_CONST_CAST(char*, aUtf8Nickname.get());
*_retval = 0;
@ -4335,7 +4337,8 @@ nsNSSCertificateDB::GetEmailSigningCert(const PRUnichar* aNickname, nsIX509Cert
nsCOMPtr<nsIInterfaceRequestor> ctx = new PipUIContext();
nsNSSCertificate *nssCert = nsnull;
char *asciiname = NULL;
asciiname = NS_CONST_CAST(char*, NS_ConvertUCS2toUTF8(aNickname).get());
NS_ConvertUCS2toUTF8 aUtf8Nickname(aNickname);
asciiname = NS_CONST_CAST(char*, aUtf8Nickname.get());
*_retval = 0;

View File

@ -194,8 +194,9 @@ NS_IMETHODIMP nsPK11Token::CheckPassword(const PRUnichar *password, PRBool *_ret
{
SECStatus srv;
PRInt32 prerr;
NS_ConvertUCS2toUTF8 aUtf8Password(password);
srv = PK11_CheckUserPassword(mSlot,
NS_CONST_CAST(char *, NS_ConvertUCS2toUTF8(password).get()));
NS_CONST_CAST(char *, aUtf8Password.get()));
if (srv != SECSuccess) {
*_retval = PR_FALSE;
prerr = PR_GetError();
@ -215,7 +216,8 @@ NS_IMETHODIMP nsPK11Token::InitPassword(const PRUnichar *initialPassword)
nsresult rv = NS_OK;
SECStatus status;
status = PK11_InitPin(mSlot, "", NS_CONST_CAST(char*, NS_ConvertUCS2toUTF8(initialPassword).get()));
NS_ConvertUCS2toUTF8 aUtf8InitialPassword(initialPassword);
status = PK11_InitPin(mSlot, "", NS_CONST_CAST(char*, aUtf8InitialPassword.get()));
if (status == SECFailure) { rv = NS_ERROR_FAILURE; goto done; }
done:
@ -257,9 +259,11 @@ nsPK11Token::SetAskPasswordDefaults(const PRInt32 askTimes,
NS_IMETHODIMP nsPK11Token::ChangePassword(const PRUnichar *oldPassword, const PRUnichar *newPassword)
{
SECStatus rv;
NS_ConvertUCS2toUTF8 aUtf8OldPassword(oldPassword);
NS_ConvertUCS2toUTF8 aUtf8NewPassword(newPassword);
rv = PK11_ChangePW(mSlot,
NS_CONST_CAST(char *, NS_ConvertUCS2toUTF8(oldPassword).get()),
NS_CONST_CAST(char *, NS_ConvertUCS2toUTF8(newPassword).get()));
NS_CONST_CAST(char *, aUtf8OldPassword.get()),
NS_CONST_CAST(char *, aUtf8NewPassword.get()));
return (rv == SECSuccess) ? NS_OK : NS_ERROR_FAILURE;
}
@ -335,7 +339,8 @@ FindTokenByName(const PRUnichar* tokenName, nsIPK11Token **_retval)
{
nsresult rv = NS_OK;
PK11SlotInfo *slot = 0;
slot = PK11_FindSlotByName(NS_CONST_CAST(char*, NS_ConvertUCS2toUTF8(tokenName).get()));
NS_ConvertUCS2toUTF8 aUtf8TokenName(tokenName);
slot = PK11_FindSlotByName(NS_CONST_CAST(char*, aUtf8TokenName.get()));
if (!slot) { rv = NS_ERROR_FAILURE; goto done; }
*_retval = new nsPK11Token(slot);

View File

@ -316,8 +316,9 @@ NS_IMETHODIMP
nsPKCS11ModuleDB::FindModuleByName(const PRUnichar *aName,
nsIPKCS11Module **_retval)
{
NS_ConvertUCS2toUTF8 aUtf8Name(aName);
SECMODModule *mod =
SECMOD_FindModule(NS_CONST_CAST(char *, NS_ConvertUCS2toUTF8(aName).get()));
SECMOD_FindModule(NS_CONST_CAST(char *, aUtf8Name.get()));
if (!mod)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIPKCS11Module> module = new nsPKCS11Module(mod);
@ -336,8 +337,9 @@ NS_IMETHODIMP
nsPKCS11ModuleDB::FindSlotByName(const PRUnichar *aName,
nsIPKCS11Slot **_retval)
{
NS_ConvertUCS2toUTF8 aUtf8Name(aName);
PK11SlotInfo *slotinfo =
PK11_FindSlotByName(NS_CONST_CAST(char*, NS_ConvertUCS2toUTF8(aName).get()));
PK11_FindSlotByName(NS_CONST_CAST(char*, aUtf8Name.get()));
if (!slotinfo)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIPKCS11Slot> slot = new nsPKCS11Slot(slotinfo);

View File

@ -31,7 +31,7 @@
* may use your version of this file under either the MPL or the
* GPL.
*
* $Id: nsPKCS12Blob.cpp,v 1.21 2001/12/16 11:44:44 jaggernaut%netscape.com Exp $
* $Id: nsPKCS12Blob.cpp,v 1.22 2002/01/16 04:30:55 kaie%netscape.com Exp $
*/
#include "prmem.h"
@ -218,8 +218,7 @@ nsPKCS12Blob::LoadCerts(const PRUnichar **certNames, int numCerts)
}
/* Add the certs */
for (int i=0; i<numCerts; i++) {
const char *name = NS_ConvertUCS2toUTF8(certNames[i]).get();
strcpy(namecpy, name);
strcpy(namecpy, NS_ConvertUCS2toUTF8(certNames[i]));
CERTCertificate *nssCert = PK11_FindCertFromNickname(namecpy, NULL);
if (!nssCert) {
if (!handleError())