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

Unified Diff: net/base/cert_status_flags.cc

Issue 14915: Move certificate verification off the IO thread.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 11 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_status_flags.h ('k') | net/base/cert_verifier.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/cert_status_flags.cc
===================================================================
--- net/base/cert_status_flags.cc (revision 0)
+++ net/base/cert_status_flags.cc (revision 0)
@@ -0,0 +1,67 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/base/cert_status_flags.h"
+
+#include "base/logging.h"
+#include "net/base/net_errors.h"
+
+namespace net {
+
+int MapNetErrorToCertStatus(int error) {
+ switch (error) {
+ case ERR_CERT_COMMON_NAME_INVALID:
+ return CERT_STATUS_COMMON_NAME_INVALID;
+ case ERR_CERT_DATE_INVALID:
+ return CERT_STATUS_DATE_INVALID;
+ case ERR_CERT_AUTHORITY_INVALID:
+ return CERT_STATUS_AUTHORITY_INVALID;
+ case ERR_CERT_NO_REVOCATION_MECHANISM:
+ return CERT_STATUS_NO_REVOCATION_MECHANISM;
+ case ERR_CERT_UNABLE_TO_CHECK_REVOCATION:
+ return CERT_STATUS_UNABLE_TO_CHECK_REVOCATION;
+ case ERR_CERT_REVOKED:
+ return CERT_STATUS_REVOKED;
+ // We added the ERR_CERT_CONTAINS_ERRORS error code when we were using
+ // WinInet, but we never figured out how it differs from ERR_CERT_INVALID.
+ // We should not use ERR_CERT_CONTAINS_ERRORS in new code.
+ case ERR_CERT_CONTAINS_ERRORS:
+ NOTREACHED();
+ // Falls through.
+ case ERR_CERT_INVALID:
+ return CERT_STATUS_INVALID;
+ default:
+ return 0;
+ }
+}
+
+int MapCertStatusToNetError(int cert_status) {
+ // A certificate may have multiple errors. We report the most
+ // serious error.
+
+ // Unrecoverable errors
+ if (cert_status & CERT_STATUS_INVALID)
+ return ERR_CERT_INVALID;
+ if (cert_status & CERT_STATUS_REVOKED)
+ return ERR_CERT_REVOKED;
+
+ // Recoverable errors
+ if (cert_status & CERT_STATUS_AUTHORITY_INVALID)
+ return ERR_CERT_AUTHORITY_INVALID;
+ if (cert_status & CERT_STATUS_COMMON_NAME_INVALID)
+ return ERR_CERT_COMMON_NAME_INVALID;
+ if (cert_status & CERT_STATUS_DATE_INVALID)
+ return ERR_CERT_DATE_INVALID;
+
+ // Unknown status. Give it the benefit of the doubt.
+ if (cert_status & CERT_STATUS_UNABLE_TO_CHECK_REVOCATION)
+ return ERR_CERT_UNABLE_TO_CHECK_REVOCATION;
+ if (cert_status & CERT_STATUS_NO_REVOCATION_MECHANISM)
+ return ERR_CERT_NO_REVOCATION_MECHANISM;
+
+ NOTREACHED();
+ return ERR_UNEXPECTED;
+}
+
+} // namespace net
Property changes on: net\base\cert_status_flags.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « net/base/cert_status_flags.h ('k') | net/base/cert_verifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698