OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/base/cert_status_flags.h" | 5 #include "net/base/cert_status_flags.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "net/base/net_errors.h" | 8 #include "net/base/net_errors.h" |
9 | 9 |
10 namespace net { | 10 namespace net { |
(...skipping 25 matching lines...) Expand all Loading... |
36 // We should not use ERR_CERT_CONTAINS_ERRORS in new code. | 36 // We should not use ERR_CERT_CONTAINS_ERRORS in new code. |
37 case ERR_CERT_CONTAINS_ERRORS: | 37 case ERR_CERT_CONTAINS_ERRORS: |
38 NOTREACHED(); | 38 NOTREACHED(); |
39 // Falls through. | 39 // Falls through. |
40 case ERR_CERT_INVALID: | 40 case ERR_CERT_INVALID: |
41 return CERT_STATUS_INVALID; | 41 return CERT_STATUS_INVALID; |
42 case ERR_CERT_WEAK_SIGNATURE_ALGORITHM: | 42 case ERR_CERT_WEAK_SIGNATURE_ALGORITHM: |
43 return CERT_STATUS_WEAK_SIGNATURE_ALGORITHM; | 43 return CERT_STATUS_WEAK_SIGNATURE_ALGORITHM; |
44 case ERR_CERT_WEAK_KEY: | 44 case ERR_CERT_WEAK_KEY: |
45 return CERT_STATUS_WEAK_KEY; | 45 return CERT_STATUS_WEAK_KEY; |
46 case ERR_CERT_NOT_IN_DNS: | |
47 return CERT_STATUS_NOT_IN_DNS; | |
48 default: | 46 default: |
49 return 0; | 47 return 0; |
50 } | 48 } |
51 } | 49 } |
52 | 50 |
53 int MapCertStatusToNetError(CertStatus cert_status) { | 51 int MapCertStatusToNetError(CertStatus cert_status) { |
54 // A certificate may have multiple errors. We report the most | 52 // A certificate may have multiple errors. We report the most |
55 // serious error. | 53 // serious error. |
56 | 54 |
57 // Unrecoverable errors | 55 // Unrecoverable errors |
(...skipping 12 matching lines...) Expand all Loading... |
70 if (cert_status & CERT_STATUS_WEAK_KEY) | 68 if (cert_status & CERT_STATUS_WEAK_KEY) |
71 return ERR_CERT_WEAK_KEY; | 69 return ERR_CERT_WEAK_KEY; |
72 if (cert_status & CERT_STATUS_DATE_INVALID) | 70 if (cert_status & CERT_STATUS_DATE_INVALID) |
73 return ERR_CERT_DATE_INVALID; | 71 return ERR_CERT_DATE_INVALID; |
74 | 72 |
75 // Unknown status. Give it the benefit of the doubt. | 73 // Unknown status. Give it the benefit of the doubt. |
76 if (cert_status & CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) | 74 if (cert_status & CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) |
77 return ERR_CERT_UNABLE_TO_CHECK_REVOCATION; | 75 return ERR_CERT_UNABLE_TO_CHECK_REVOCATION; |
78 if (cert_status & CERT_STATUS_NO_REVOCATION_MECHANISM) | 76 if (cert_status & CERT_STATUS_NO_REVOCATION_MECHANISM) |
79 return ERR_CERT_NO_REVOCATION_MECHANISM; | 77 return ERR_CERT_NO_REVOCATION_MECHANISM; |
80 if (cert_status & CERT_STATUS_NOT_IN_DNS) | |
81 return ERR_CERT_NOT_IN_DNS; | |
82 | 78 |
83 NOTREACHED(); | 79 NOTREACHED(); |
84 return ERR_UNEXPECTED; | 80 return ERR_UNEXPECTED; |
85 } | 81 } |
86 | 82 |
87 } // namespace net | 83 } // namespace net |
OLD | NEW |