Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Unified Diff: net/base/cert_database_nss.cc

Issue 7272014: Mark untrusted certificates as such in Linux UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ... Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/cert_database.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/cert_database_nss.cc
diff --git a/net/base/cert_database_nss.cc b/net/base/cert_database_nss.cc
index e198e3504be82298c9b3354b0ae08e81be425a1f..e3f2d6306bd296bdde2d054607a9a1278bda4182 100644
--- a/net/base/cert_database_nss.cc
+++ b/net/base/cert_database_nss.cc
@@ -21,6 +21,12 @@
#include "net/third_party/mozilla_security_manager/nsNSSCertTrust.h"
#include "net/third_party/mozilla_security_manager/nsPKCS12Blob.h"
+// In NSS 3.13, CERTDB_VALID_PEER was renamed CERTDB_TERMINAL_RECORD. So we use
+// the new name of the macro.
+#if !defined(CERTDB_TERMINAL_RECORD)
+#define CERTDB_TERMINAL_RECORD CERTDB_VALID_PEER
+#endif
+
// PSM = Mozilla's Personal Security Manager.
namespace psm = mozilla_security_manager;
@@ -236,6 +242,40 @@ CertDatabase::TrustBits CertDatabase::GetCertTrust(const X509Certificate* cert,
}
}
+bool CertDatabase::IsUntrusted(const X509Certificate* cert) const {
+ CERTCertTrust nsstrust;
+ SECStatus rv = CERT_GetCertTrust(cert->os_cert_handle(), &nsstrust);
+ if (rv != SECSuccess) {
+ LOG(ERROR) << "CERT_GetCertTrust failed with error " << PORT_GetError();
+ return false;
+ }
+
+ // Handle explicitly distrusted certificates.
+ static const unsigned int kTrusted = CERTDB_TRUSTED_CA | CERTDB_TRUSTED;
+ const bool has_no_trust_flags =
+ (nsstrust.sslFlags & kTrusted) == 0 &&
+ (nsstrust.emailFlags & kTrusted) == 0 &&
+ (nsstrust.objectSigningFlags & kTrusted) == 0;
+
+ unsigned int flags = SEC_GET_TRUST_FLAGS(&nsstrust, trustSSL);
+ if (flags & CERTDB_TERMINAL_RECORD) {
wtc 2011/09/21 21:49:21 Also the CERTDB_TERMINAL_RECORD bit needs to be te
+ // In a terminal trust record, three bits may be set: CERTDB_VALID_CA,
+ // CERTDB_TRUSTED_CA, and CERTDB_TRUSTED. The CERTDB_VALID_CA bit is
+ // irrelevant to distrust, so we don't test that bit.
+ return has_no_trust_flags;
wtc 2011/09/21 19:01:13 The boolean expression has_no_trust_flags is wrong
+ }
+
+ // Self-signed certificates that don't have any trust bits set are untrusted.
+ // Other certificates that don't have any trust bits set may still be trusted
+ // if they chain up to a trust anchor.
+ if (CERT_CompareName(&cert->os_cert_handle()->issuer,
+ &cert->os_cert_handle()->subject) == SECEqual) {
+ return has_no_trust_flags;
+ }
+
+ return false;
+}
+
bool CertDatabase::SetCertTrust(const X509Certificate* cert,
CertType type,
TrustBits trust_bits) {
« no previous file with comments | « net/base/cert_database.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698