diff options
author | joaodasilva@chromium.org <joaodasilva@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-10 14:11:07 +0000 |
---|---|---|
committer | joaodasilva@chromium.org <joaodasilva@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-10 14:11:07 +0000 |
commit | 7fda9a408391ef66ba65bdb734bdcce28e624930 (patch) | |
tree | 02d274a5c4aa0b1fa338058eda4e00191b9608d0 /net/third_party | |
parent | 92c20da406d882936b345122545fd7b295fce91f (diff) | |
download | chromium_src-7fda9a408391ef66ba65bdb734bdcce28e624930.zip chromium_src-7fda9a408391ef66ba65bdb734bdcce28e624930.tar.gz chromium_src-7fda9a408391ef66ba65bdb734bdcce28e624930.tar.bz2 |
Move the NSS functions out of CertDatabase into a new NSSCertDatabase class.
BUG=chromium-os:33872
Review URL: https://chromiumcodereview.appspot.com/10916094
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@155720 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/third_party')
-rw-r--r-- | net/third_party/mozilla_security_manager/nsNSSCertificateDB.cpp | 55 | ||||
-rw-r--r-- | net/third_party/mozilla_security_manager/nsNSSCertificateDB.h | 15 |
2 files changed, 36 insertions, 34 deletions
diff --git a/net/third_party/mozilla_security_manager/nsNSSCertificateDB.cpp b/net/third_party/mozilla_security_manager/nsNSSCertificateDB.cpp index 234c065..89d0191 100644 --- a/net/third_party/mozilla_security_manager/nsNSSCertificateDB.cpp +++ b/net/third_party/mozilla_security_manager/nsNSSCertificateDB.cpp @@ -62,8 +62,8 @@ namespace mozilla_security_manager { // Based on nsNSSCertificateDB::handleCACertDownload, minus the UI bits. bool ImportCACerts(const net::CertificateList& certificates, net::X509Certificate* root, - net::CertDatabase::TrustBits trustBits, - net::CertDatabase::ImportCertFailureList* not_imported) { + net::NSSCertDatabase::TrustBits trustBits, + net::NSSCertDatabase::ImportCertFailureList* not_imported) { if (certificates.empty() || !root) return false; @@ -78,14 +78,14 @@ bool ImportCACerts(const net::CertificateList& certificates, // itself, so we skip it here. if (!CERT_IsCACert(root->os_cert_handle(), NULL)) { - not_imported->push_back(net::CertDatabase::ImportCertFailure( + not_imported->push_back(net::NSSCertDatabase::ImportCertFailure( root, net::ERR_IMPORT_CA_CERT_NOT_CA)); } else if (root->os_cert_handle()->isperm) { // Mozilla just returns here, but we continue in case there are other certs // in the list which aren't already imported. // TODO(mattm): should we set/add trust if it differs from the present // settings? - not_imported->push_back(net::CertDatabase::ImportCertFailure( + not_imported->push_back(net::NSSCertDatabase::ImportCertFailure( root, net::ERR_IMPORT_CERT_ALREADY_EXISTS)); } else { // Mozilla uses CERT_AddTempCertToPerm, however it is privately exported, @@ -122,14 +122,14 @@ bool ImportCACerts(const net::CertificateList& certificates, // Mozilla uses CERT_FilterCertListByUsage(certList, certUsageAnyCA, // PR_TRUE). Afaict, checking !CERT_IsCACert on each cert is equivalent. if (!CERT_IsCACert(cert->os_cert_handle(), NULL)) { - not_imported->push_back(net::CertDatabase::ImportCertFailure( + not_imported->push_back(net::NSSCertDatabase::ImportCertFailure( cert, net::ERR_IMPORT_CA_CERT_NOT_CA)); VLOG(1) << "skipping cert (non-ca)"; continue; } if (cert->os_cert_handle()->isperm) { - not_imported->push_back(net::CertDatabase::ImportCertFailure( + not_imported->push_back(net::NSSCertDatabase::ImportCertFailure( cert, net::ERR_IMPORT_CERT_ALREADY_EXISTS)); VLOG(1) << "skipping cert (perm)"; continue; @@ -140,7 +140,7 @@ bool ImportCACerts(const net::CertificateList& certificates, // TODO(mattm): use better error code (map PORT_GetError to an appropriate // error value). (maybe make MapSecurityError or MapCertErrorToCertStatus // public.) - not_imported->push_back(net::CertDatabase::ImportCertFailure( + not_imported->push_back(net::NSSCertDatabase::ImportCertFailure( cert, net::ERR_FAILED)); VLOG(1) << "skipping cert (verify) " << PORT_GetError(); continue; @@ -158,7 +158,7 @@ bool ImportCACerts(const net::CertificateList& certificates, LOG(ERROR) << "PK11_ImportCert failed with error " << PORT_GetError(); // TODO(mattm): Should we bail or continue on error here? Mozilla doesn't // check error code at all. - not_imported->push_back(net::CertDatabase::ImportCertFailure( + not_imported->push_back(net::NSSCertDatabase::ImportCertFailure( cert, net::ERR_IMPORT_CA_CERT_FAILED)); } } @@ -168,9 +168,10 @@ bool ImportCACerts(const net::CertificateList& certificates, } // Based on nsNSSCertificateDB::ImportServerCertificate. -bool ImportServerCert(const net::CertificateList& certificates, - net::CertDatabase::TrustBits trustBits, - net::CertDatabase::ImportCertFailureList* not_imported) { +bool ImportServerCert( + const net::CertificateList& certificates, + net::NSSCertDatabase::TrustBits trustBits, + net::NSSCertDatabase::ImportCertFailureList* not_imported) { if (certificates.empty()) return false; @@ -193,7 +194,7 @@ bool ImportServerCert(const net::CertificateList& certificates, PR_FALSE /* includeTrust (unused) */); if (srv != SECSuccess) { LOG(ERROR) << "PK11_ImportCert failed with error " << PORT_GetError(); - not_imported->push_back(net::CertDatabase::ImportCertFailure( + not_imported->push_back(net::NSSCertDatabase::ImportCertFailure( cert, net::ERR_IMPORT_SERVER_CERT_FAILED)); continue; } @@ -211,14 +212,14 @@ bool ImportServerCert(const net::CertificateList& certificates, bool SetCertTrust(const net::X509Certificate* cert, net::CertType type, - net::CertDatabase::TrustBits trustBits) + net::NSSCertDatabase::TrustBits trustBits) { - const unsigned kSSLTrustBits = net::CertDatabase::TRUSTED_SSL | - net::CertDatabase::DISTRUSTED_SSL; - const unsigned kEmailTrustBits = net::CertDatabase::TRUSTED_EMAIL | - net::CertDatabase::DISTRUSTED_EMAIL; - const unsigned kObjSignTrustBits = net::CertDatabase::TRUSTED_OBJ_SIGN | - net::CertDatabase::DISTRUSTED_OBJ_SIGN; + const unsigned kSSLTrustBits = net::NSSCertDatabase::TRUSTED_SSL | + net::NSSCertDatabase::DISTRUSTED_SSL; + const unsigned kEmailTrustBits = net::NSSCertDatabase::TRUSTED_EMAIL | + net::NSSCertDatabase::DISTRUSTED_EMAIL; + const unsigned kObjSignTrustBits = net::NSSCertDatabase::TRUSTED_OBJ_SIGN | + net::NSSCertDatabase::DISTRUSTED_OBJ_SIGN; if ((trustBits & kSSLTrustBits) == kSSLTrustBits || (trustBits & kEmailTrustBits) == kEmailTrustBits || (trustBits & kObjSignTrustBits) == kObjSignTrustBits) { @@ -236,19 +237,19 @@ SetCertTrust(const net::X509Certificate* cert, // CERTDB_TERMINAL_RECORD only. CERTCertTrust trust = {CERTDB_VALID_CA, CERTDB_VALID_CA, CERTDB_VALID_CA}; - if (trustBits & net::CertDatabase::DISTRUSTED_SSL) + if (trustBits & net::NSSCertDatabase::DISTRUSTED_SSL) trust.sslFlags = CERTDB_TERMINAL_RECORD; - else if (trustBits & net::CertDatabase::TRUSTED_SSL) + else if (trustBits & net::NSSCertDatabase::TRUSTED_SSL) trust.sslFlags |= CERTDB_TRUSTED_CA | CERTDB_TRUSTED_CLIENT_CA; - if (trustBits & net::CertDatabase::DISTRUSTED_EMAIL) + if (trustBits & net::NSSCertDatabase::DISTRUSTED_EMAIL) trust.emailFlags = CERTDB_TERMINAL_RECORD; - else if (trustBits & net::CertDatabase::TRUSTED_EMAIL) + else if (trustBits & net::NSSCertDatabase::TRUSTED_EMAIL) trust.emailFlags |= CERTDB_TRUSTED_CA | CERTDB_TRUSTED_CLIENT_CA; - if (trustBits & net::CertDatabase::DISTRUSTED_OBJ_SIGN) + if (trustBits & net::NSSCertDatabase::DISTRUSTED_OBJ_SIGN) trust.objectSigningFlags = CERTDB_TERMINAL_RECORD; - else if (trustBits & net::CertDatabase::TRUSTED_OBJ_SIGN) + else if (trustBits & net::NSSCertDatabase::TRUSTED_OBJ_SIGN) trust.objectSigningFlags |= CERTDB_TRUSTED_CA | CERTDB_TRUSTED_CLIENT_CA; srv = CERT_ChangeCertTrust(CERT_GetDefaultCertDB(), nsscert, &trust); @@ -258,9 +259,9 @@ SetCertTrust(const net::X509Certificate* cert, CERT_GetCertTrust(nsscert, &trust); trust.sslFlags = 0; - if (trustBits & net::CertDatabase::DISTRUSTED_SSL) + if (trustBits & net::NSSCertDatabase::DISTRUSTED_SSL) trust.sslFlags |= CERTDB_TERMINAL_RECORD; - else if (trustBits & net::CertDatabase::TRUSTED_SSL) + else if (trustBits & net::NSSCertDatabase::TRUSTED_SSL) trust.sslFlags |= CERTDB_TRUSTED | CERTDB_TERMINAL_RECORD; srv = CERT_ChangeCertTrust(CERT_GetDefaultCertDB(), nsscert, &trust); diff --git a/net/third_party/mozilla_security_manager/nsNSSCertificateDB.h b/net/third_party/mozilla_security_manager/nsNSSCertificateDB.h index e7a5a103..0e5b33b 100644 --- a/net/third_party/mozilla_security_manager/nsNSSCertificateDB.h +++ b/net/third_party/mozilla_security_manager/nsNSSCertificateDB.h @@ -42,7 +42,7 @@ #include <vector> #include "base/memory/ref_counted.h" -#include "net/base/cert_database.h" +#include "net/base/nss_cert_database.h" typedef struct CERTCertificateStr CERTCertificate; namespace net { @@ -54,16 +54,17 @@ namespace mozilla_security_manager { bool ImportCACerts(const net::CertificateList& certificates, net::X509Certificate* root, - net::CertDatabase::TrustBits trustBits, - net::CertDatabase::ImportCertFailureList* not_imported); + net::NSSCertDatabase::TrustBits trustBits, + net::NSSCertDatabase::ImportCertFailureList* not_imported); -bool ImportServerCert(const net::CertificateList& certificates, - net::CertDatabase::TrustBits trustBits, - net::CertDatabase::ImportCertFailureList* not_imported); +bool ImportServerCert( + const net::CertificateList& certificates, + net::NSSCertDatabase::TrustBits trustBits, + net::NSSCertDatabase::ImportCertFailureList* not_imported); bool SetCertTrust(const net::X509Certificate* cert, net::CertType type, - net::CertDatabase::TrustBits trustBits); + net::NSSCertDatabase::TrustBits trustBits); } // namespace mozilla_security_manager |