mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 879135, Part 1: Remove nsNSSComponent::RememberCert, r=cviecco
--HG-- extra : rebase_source : 4dfe0052a653ceccd04192c2ef0f152983cbc2d2
This commit is contained in:
parent
97dd8c7835
commit
aea6f290f0
@ -120,75 +120,6 @@ extern char* pk11PasswordPrompt(PK11SlotInfo *slot, PRBool retry, void *arg);
|
||||
#define PIPNSS_STRBUNDLE_URL "chrome://pipnss/locale/pipnss.properties"
|
||||
#define NSSERR_STRBUNDLE_URL "chrome://pipnss/locale/nsserrors.properties"
|
||||
|
||||
static PLHashNumber certHashtable_keyHash(const void *key)
|
||||
{
|
||||
if (!key)
|
||||
return 0;
|
||||
|
||||
SECItem *certKey = (SECItem*)key;
|
||||
|
||||
// lazy hash function, sum up all char values of SECItem
|
||||
|
||||
PLHashNumber hash = 0;
|
||||
unsigned int i = 0;
|
||||
unsigned char *c = certKey->data;
|
||||
|
||||
for (i = 0; i < certKey->len; ++i, ++c) {
|
||||
hash += *c;
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
static int certHashtable_keyCompare(const void *k1, const void *k2)
|
||||
{
|
||||
// return type is a bool, answering the question "are the keys equal?"
|
||||
|
||||
if (!k1 || !k2)
|
||||
return false;
|
||||
|
||||
SECItem *certKey1 = (SECItem*)k1;
|
||||
SECItem *certKey2 = (SECItem*)k2;
|
||||
|
||||
if (certKey1->len != certKey2->len) {
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned int i = 0;
|
||||
unsigned char *c1 = certKey1->data;
|
||||
unsigned char *c2 = certKey2->data;
|
||||
|
||||
for (i = 0; i < certKey1->len; ++i, ++c1, ++c2) {
|
||||
if (*c1 != *c2) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static int certHashtable_valueCompare(const void *v1, const void *v2)
|
||||
{
|
||||
// two values are identical if their keys are identical
|
||||
|
||||
if (!v1 || !v2)
|
||||
return false;
|
||||
|
||||
CERTCertificate *cert1 = (CERTCertificate*)v1;
|
||||
CERTCertificate *cert2 = (CERTCertificate*)v2;
|
||||
|
||||
return certHashtable_keyCompare(&cert1->certKey, &cert2->certKey);
|
||||
}
|
||||
|
||||
static int certHashtable_clearEntry(PLHashEntry *he, int /*index*/, void * /*userdata*/)
|
||||
{
|
||||
if (he && he->value) {
|
||||
CERT_DestroyCertificate((CERTCertificate*)he->value);
|
||||
}
|
||||
|
||||
return HT_ENUMERATE_NEXT;
|
||||
}
|
||||
|
||||
class CRLDownloadEvent : public nsRunnable {
|
||||
public:
|
||||
CRLDownloadEvent(const nsCSubstring &urlString, nsIStreamListener *listener)
|
||||
@ -365,7 +296,6 @@ nsNSSComponent::nsNSSComponent()
|
||||
|
||||
NS_ASSERTION( (0 == mInstanceCount), "nsNSSComponent is a singleton, but instantiated multiple times!");
|
||||
++mInstanceCount;
|
||||
hashTableCerts = nullptr;
|
||||
mShutdownObjectList = nsNSSShutDownList::construct();
|
||||
mIsNetworkDown = false;
|
||||
}
|
||||
@ -1555,9 +1485,6 @@ nsNSSComponent::InitializeNSS(bool showWarningBox)
|
||||
}
|
||||
}
|
||||
|
||||
hashTableCerts = PL_NewHashTable( 0, certHashtable_keyHash, certHashtable_keyCompare,
|
||||
certHashtable_valueCompare, 0, 0 );
|
||||
|
||||
#ifndef NSS_NO_LIBPKIX
|
||||
rv = mPrefBranch->GetBoolPref("security.use_libpkix_verification", &globalConstFlagUsePKIXVerification);
|
||||
if (NS_FAILED(rv))
|
||||
@ -1734,12 +1661,6 @@ nsNSSComponent::ShutdownNSS()
|
||||
|
||||
MutexAutoLock lock(mutex);
|
||||
|
||||
if (hashTableCerts) {
|
||||
PL_HashTableEnumerateEntries(hashTableCerts, certHashtable_clearEntry, 0);
|
||||
PL_HashTableDestroy(hashTableCerts);
|
||||
hashTableCerts = nullptr;
|
||||
}
|
||||
|
||||
if (mNSSInitialized) {
|
||||
mNSSInitialized = false;
|
||||
|
||||
@ -2293,37 +2214,6 @@ nsNSSComponent::DeregisterObservers()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNSSComponent::RememberCert(CERTCertificate *cert)
|
||||
{
|
||||
nsNSSShutDownPreventionLock locker;
|
||||
|
||||
// Must not interfere with init / shutdown / profile switch.
|
||||
|
||||
MutexAutoLock lock(mutex);
|
||||
|
||||
if (!hashTableCerts || !cert)
|
||||
return NS_OK;
|
||||
|
||||
void *found = PL_HashTableLookup(hashTableCerts, (void*)&cert->certKey);
|
||||
|
||||
if (found) {
|
||||
// we remember that cert already
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
CERTCertificate *myDupCert = CERT_DupCertificate(cert);
|
||||
|
||||
if (!myDupCert)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (!PL_HashTableAdd(hashTableCerts, (void*)&myDupCert->certKey, myDupCert)) {
|
||||
CERT_DestroyCertificate(myDupCert);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsNSSComponent::DoProfileChangeNetTeardown()
|
||||
{
|
||||
|
@ -139,8 +139,6 @@ class NS_NO_VTABLE nsINSSComponent : public nsISupports {
|
||||
// values in the preferences.
|
||||
NS_IMETHOD SkipOcspOff() = 0;
|
||||
|
||||
NS_IMETHOD RememberCert(CERTCertificate *cert) = 0;
|
||||
|
||||
NS_IMETHOD RemoveCrlFromList(nsAutoString) = 0;
|
||||
|
||||
NS_IMETHOD DefineNextTimer() = 0;
|
||||
@ -256,7 +254,6 @@ public:
|
||||
NS_IMETHOD DefineNextTimer();
|
||||
NS_IMETHOD LogoutAuthenticatedPK11();
|
||||
NS_IMETHOD DownloadCRLDirectly(nsAutoString, nsAutoString);
|
||||
NS_IMETHOD RememberCert(CERTCertificate *cert);
|
||||
|
||||
#ifndef MOZ_DISABLE_CRYPTOLEGACY
|
||||
NS_IMETHOD LaunchSmartCardThread(SECMODModule *module);
|
||||
@ -311,7 +308,6 @@ private:
|
||||
nsCOMPtr<nsITimer> mTimer;
|
||||
bool mNSSInitialized;
|
||||
bool mObserversRegistered;
|
||||
PLHashTable *hashTableCerts;
|
||||
nsAutoString mDownloadURL;
|
||||
nsAutoString mCrlUpdateKey;
|
||||
Mutex mCrlTimerLock;
|
||||
|
Loading…
Reference in New Issue
Block a user