From 3ece8d7a91c3f7f1c65de823ffb075ffdc88405c Mon Sep 17 00:00:00 2001 From: "kaie%netscape.com" Date: Tue, 8 Jul 2003 14:41:02 +0000 Subject: [PATCH] b=195574 SSL extremely flaky if Ask for Master Password is 'Every time' r=darin sr=brendan git-svn-id: svn://10.0.0.236/trunk@144562 18797224-902f-48f8-a5cc-f745e15eee43 --- .../extensions/wallet/src/nsWalletService.cpp | 4 ++-- mozilla/extensions/wallet/src/wallet.cpp | 9 +++++++++ mozilla/extensions/wallet/src/wallet.h | 3 +++ .../base/public/nsISecretDecoderRing.idl | 4 ++++ mozilla/security/manager/ssl/src/nsSDR.cpp | 18 +++++++++++++++++- 5 files changed, 35 insertions(+), 3 deletions(-) diff --git a/mozilla/extensions/wallet/src/nsWalletService.cpp b/mozilla/extensions/wallet/src/nsWalletService.cpp index c4ad9200eb0..00ab47daf7f 100644 --- a/mozilla/extensions/wallet/src/nsWalletService.cpp +++ b/mozilla/extensions/wallet/src/nsWalletService.cpp @@ -309,7 +309,7 @@ ExpireMasterPasswordPrefChanged(const char * newpref, void * data) { } if (expireMasterPassword) { PRBool status; - WLLT_ExpirePassword(&status); + WLLT_ExpirePasswordOnly(&status); } return 0; } @@ -495,7 +495,7 @@ nsWalletlibService::OnStateChange(nsIWebProgress* aWebProgress, } if (expireMasterPassword) { PRBool status; - WLLT_ExpirePassword(&status); + WLLT_ExpirePasswordOnly(&status); } } } diff --git a/mozilla/extensions/wallet/src/wallet.cpp b/mozilla/extensions/wallet/src/wallet.cpp index 310db3b65a7..0b56c93650c 100644 --- a/mozilla/extensions/wallet/src/wallet.cpp +++ b/mozilla/extensions/wallet/src/wallet.cpp @@ -769,6 +769,15 @@ PRIVATE nsresult DecryptString (const char * crypt, char *& text) { PUBLIC void WLLT_ExpirePassword(PRBool* status) { + nsresult rv = wallet_CryptSetup(); + if (NS_SUCCEEDED(rv)) { + rv = gSecretDecoderRing->LogoutAndTeardown(); + } + *status = NS_SUCCEEDED(rv); +} + +PUBLIC void +WLLT_ExpirePasswordOnly(PRBool* status) { nsresult rv = wallet_CryptSetup(); if (NS_SUCCEEDED(rv)) { rv = gSecretDecoderRing->Logout(); diff --git a/mozilla/extensions/wallet/src/wallet.h b/mozilla/extensions/wallet/src/wallet.h index 6c4f24ecc75..306b13a36cf 100644 --- a/mozilla/extensions/wallet/src/wallet.h +++ b/mozilla/extensions/wallet/src/wallet.h @@ -114,6 +114,9 @@ WLLT_FetchFromNetCenter(); extern void WLLT_ExpirePassword(PRBool* status); +extern void +WLLT_ExpirePasswordOnly(PRBool* status); + extern void WLLT_InitReencryptCallback(nsIDOMWindowInternal* window); diff --git a/mozilla/netwerk/base/public/nsISecretDecoderRing.idl b/mozilla/netwerk/base/public/nsISecretDecoderRing.idl index 70edad71a51..3883309c7f6 100644 --- a/mozilla/netwerk/base/public/nsISecretDecoderRing.idl +++ b/mozilla/netwerk/base/public/nsISecretDecoderRing.idl @@ -63,6 +63,10 @@ interface nsISecretDecoderRing: nsISupports { /* Logout of the security device that protects the SDR key */ void logout(); + + /* Logout of the security device that protects the SDR key + and tear down authenticated objects. */ + void logoutAndTeardown(); }; /* diff --git a/mozilla/security/manager/ssl/src/nsSDR.cpp b/mozilla/security/manager/ssl/src/nsSDR.cpp index ea85ac153a5..ac1db2a8517 100644 --- a/mozilla/security/manager/ssl/src/nsSDR.cpp +++ b/mozilla/security/manager/ssl/src/nsSDR.cpp @@ -308,7 +308,7 @@ ChangePassword() } static NS_DEFINE_CID(kNSSComponentCID, NS_NSSCOMPONENT_CID); -/* void logout(); */ + NS_IMETHODIMP nsSecretDecoderRing:: Logout() { @@ -322,6 +322,22 @@ Logout() PK11_LogoutAll(); } + return NS_OK; +} + +NS_IMETHODIMP nsSecretDecoderRing:: +LogoutAndTeardown() +{ + nsresult rv; + nsCOMPtr nssComponent(do_GetService(kNSSComponentCID, &rv)); + if (NS_FAILED(rv)) + return rv; + + { + nsNSSShutDownPreventionLock locker; + PK11_LogoutAll(); + } + return nssComponent->LogoutAuthenticatedPK11(); }