b=110420 fix cert prompt dialogs
r=javi sr=shaver
This commit is contained in:
Родитель
32e3bec165
Коммит
882c35c877
|
@ -731,15 +731,14 @@ nsNSSDialogs::ChooseCertificate(nsIInterfaceRequestor *ctx, const PRUnichar *cn,
|
|||
nsCOMPtr<nsIDialogParamBlock> block(do_CreateInstance("@mozilla.org/embedcomp/dialogparam;1"));
|
||||
if (!block) return NS_ERROR_FAILURE;
|
||||
|
||||
// void ChangePassword(in wstring tokenName, out int status);
|
||||
block->SetNumberStrings(4+count*2);
|
||||
|
||||
rv = block->SetString(1, cn);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// void ChangePassword(in wstring tokenName, out int status);
|
||||
rv = block->SetString(2, organization);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// void ChangePassword(in wstring tokenName, out int status);
|
||||
rv = block->SetString(3, issuer);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
@ -789,6 +788,8 @@ nsNSSDialogs::PickCertificate(nsIInterfaceRequestor *ctx, const PRUnichar *title
|
|||
nsCOMPtr<nsIDialogParamBlock> block(do_CreateInstance("@mozilla.org/embedcomp/dialogparam;1"));
|
||||
if (!block) return NS_ERROR_FAILURE;
|
||||
|
||||
block->SetNumberStrings(3+count*2);
|
||||
|
||||
rv = block->SetString(1, title);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
@ -939,6 +940,8 @@ nsNSSDialogs::ChooseToken(nsIInterfaceRequestor *aCtx, const PRUnichar **aTokenL
|
|||
nsCOMPtr<nsIDialogParamBlock> block(do_CreateInstance("@mozilla.org/embedcomp/dialogparam;1"));
|
||||
if (!block) return NS_ERROR_FAILURE;
|
||||
|
||||
block->SetNumberStrings(aCount);
|
||||
|
||||
for (i = 0; i < aCount; i++) {
|
||||
rv = block->SetString(i+1, aTokenList[i]);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
|
|
@ -66,7 +66,6 @@ nsCertPicker::~nsCertPicker()
|
|||
/* nsIX509Cert pick (in nsIInterfaceRequestor ctx, in wstring title, in wstring infoPrompt, in PRInt32 certUsage, in boolean allowInvalid, in boolean allowDuplicateNicknames, out boolean canceled); */
|
||||
NS_IMETHODIMP nsCertPicker::PickByUsage(nsIInterfaceRequestor *ctx, const PRUnichar *title, const PRUnichar *infoPrompt, PRInt32 certUsage, PRBool allowInvalid, PRBool allowDuplicateNicknames, PRBool *canceled, nsIX509Cert **_retval)
|
||||
{
|
||||
PRInt32 i = 0;
|
||||
PRInt32 selectedIndex = -1;
|
||||
PRUnichar **certNicknameList = nsnull;
|
||||
PRUnichar **certDetailsList = nsnull;
|
||||
|
@ -111,12 +110,15 @@ NS_IMETHODIMP nsCertPicker::PickByUsage(nsIInterfaceRequestor *ctx, const PRUnic
|
|||
certNicknameList = (PRUnichar **)nsMemory::Alloc(sizeof(PRUnichar *) * nicknames->numnicknames);
|
||||
certDetailsList = (PRUnichar **)nsMemory::Alloc(sizeof(PRUnichar *) * nicknames->numnicknames);
|
||||
|
||||
for (i = 0, node = CERT_LIST_HEAD(certList);
|
||||
!CERT_LIST_END(node, certList);
|
||||
++i, node = CERT_LIST_NEXT(node)
|
||||
PRInt32 CertsToUse;
|
||||
|
||||
for (CertsToUse = 0, node = CERT_LIST_HEAD(certList);
|
||||
!CERT_LIST_END(node, certList) && CertsToUse < nicknames->numnicknames;
|
||||
node = CERT_LIST_NEXT(node)
|
||||
)
|
||||
{
|
||||
nsNSSCertificate *tempCert = new nsNSSCertificate(node->cert);
|
||||
|
||||
if (tempCert) {
|
||||
|
||||
// XXX we really should be using an nsCOMPtr instead of manually add-refing,
|
||||
|
@ -124,19 +126,26 @@ NS_IMETHODIMP nsCertPicker::PickByUsage(nsIInterfaceRequestor *ctx, const PRUnic
|
|||
|
||||
NS_ADDREF(tempCert);
|
||||
|
||||
nsAutoString i_nickname(NS_ConvertUTF8toUCS2(nicknames->nicknames[i]));
|
||||
nsAutoString i_nickname(NS_ConvertUTF8toUCS2(nicknames->nicknames[CertsToUse]));
|
||||
nsAutoString nickWithSerial;
|
||||
nsAutoString details;
|
||||
|
||||
if (NS_SUCCEEDED(tempCert->FormatUIStrings(i_nickname, nickWithSerial, details))) {
|
||||
certNicknameList[i] = ToNewUnicode(nickWithSerial);
|
||||
certDetailsList[i] = ToNewUnicode(details);
|
||||
certNicknameList[CertsToUse] = ToNewUnicode(nickWithSerial);
|
||||
certDetailsList[CertsToUse] = ToNewUnicode(details);
|
||||
}
|
||||
else {
|
||||
certNicknameList[CertsToUse] = nsnull;
|
||||
certDetailsList[CertsToUse] = nsnull;
|
||||
}
|
||||
|
||||
NS_RELEASE(tempCert);
|
||||
|
||||
++CertsToUse;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PRInt32 i = 0;
|
||||
nsICertPickDialogs *dialogs = nsnull;
|
||||
rv = getNSSDialogs((void**)&dialogs, NS_GET_IID(nsICertPickDialogs));
|
||||
|
||||
|
@ -144,9 +153,9 @@ NS_IMETHODIMP nsCertPicker::PickByUsage(nsIInterfaceRequestor *ctx, const PRUnic
|
|||
/* Throw up the cert picker dialog and get back the index of the selected cert */
|
||||
rv = dialogs->PickCertificate(ctx, title, infoPrompt,
|
||||
(const PRUnichar**)certNicknameList, (const PRUnichar**)certDetailsList,
|
||||
nicknames->numnicknames, &selectedIndex, canceled);
|
||||
CertsToUse, &selectedIndex, canceled);
|
||||
|
||||
for (i = 0; i < nicknames->numnicknames; ++i) {
|
||||
for (i = 0; i < CertsToUse; ++i) {
|
||||
nsMemory::Free(certNicknameList[i]);
|
||||
nsMemory::Free(certDetailsList[i]);
|
||||
}
|
||||
|
@ -188,5 +197,5 @@ NS_IMETHODIMP nsCertPicker::PickByUsage(nsIInterfaceRequestor *ctx, const PRUnic
|
|||
if (certList) {
|
||||
CERT_DestroyCertList(certList);
|
||||
}
|
||||
return NS_OK;
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -1637,7 +1637,6 @@ SECStatus nsNSS_SSLGetClientAuthData(void* arg, PRFileDesc* socket,
|
|||
}
|
||||
else {
|
||||
/* user selects a cert to present */
|
||||
int i;
|
||||
nsIClientAuthDialogs *dialogs = NULL;
|
||||
PRInt32 selectedIndex = -1;
|
||||
PRUnichar **certNicknameList = NULL;
|
||||
|
@ -1716,12 +1715,15 @@ SECStatus nsNSS_SSLGetClientAuthData(void* arg, PRFileDesc* socket,
|
|||
certNicknameList = (PRUnichar **)nsMemory::Alloc(sizeof(PRUnichar *) * nicknames->numnicknames);
|
||||
certDetailsList = (PRUnichar **)nsMemory::Alloc(sizeof(PRUnichar *) * nicknames->numnicknames);
|
||||
|
||||
for (i = 0, node = CERT_LIST_HEAD(certList);
|
||||
!CERT_LIST_END(node, certList);
|
||||
++i, node = CERT_LIST_NEXT(node)
|
||||
PRInt32 CertsToUse;
|
||||
|
||||
for (CertsToUse = 0, node = CERT_LIST_HEAD(certList);
|
||||
!CERT_LIST_END(node, certList) && CertsToUse < nicknames->numnicknames;
|
||||
node = CERT_LIST_NEXT(node)
|
||||
)
|
||||
{
|
||||
nsNSSCertificate *tempCert = new nsNSSCertificate(node->cert);
|
||||
|
||||
if (tempCert) {
|
||||
|
||||
// XXX we really should be using an nsCOMPtr instead of manually add-refing,
|
||||
|
@ -1729,15 +1731,21 @@ SECStatus nsNSS_SSLGetClientAuthData(void* arg, PRFileDesc* socket,
|
|||
|
||||
NS_ADDREF(tempCert);
|
||||
|
||||
nsAutoString i_nickname(NS_ConvertUTF8toUCS2(nicknames->nicknames[i]));
|
||||
nsAutoString i_nickname(NS_ConvertUTF8toUCS2(nicknames->nicknames[CertsToUse]));
|
||||
nsAutoString nickWithSerial;
|
||||
nsAutoString details;
|
||||
if (NS_SUCCEEDED(tempCert->FormatUIStrings(i_nickname, nickWithSerial, details))) {
|
||||
certNicknameList[i] = ToNewUnicode(nickWithSerial);
|
||||
certDetailsList[i] = ToNewUnicode(details);
|
||||
certNicknameList[CertsToUse] = ToNewUnicode(nickWithSerial);
|
||||
certDetailsList[CertsToUse] = ToNewUnicode(details);
|
||||
}
|
||||
else {
|
||||
certNicknameList[CertsToUse] = nsnull;
|
||||
certDetailsList[CertsToUse] = nsnull;
|
||||
}
|
||||
|
||||
NS_RELEASE(tempCert);
|
||||
|
||||
++CertsToUse;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1748,9 +1756,10 @@ SECStatus nsNSS_SSLGetClientAuthData(void* arg, PRFileDesc* socket,
|
|||
|
||||
rv = dialogs->ChooseCertificate(info, cn.get(), org.get(), issuer.get(),
|
||||
(const PRUnichar**)certNicknameList, (const PRUnichar**)certDetailsList,
|
||||
nicknames->numnicknames, &selectedIndex, &canceled);
|
||||
CertsToUse, &selectedIndex, &canceled);
|
||||
|
||||
for (i = 0; i < nicknames->numnicknames; ++i) {
|
||||
int i;
|
||||
for (i = 0; i < CertsToUse; ++i) {
|
||||
nsMemory::Free(certNicknameList[i]);
|
||||
nsMemory::Free(certDetailsList[i]);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче