OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 13 matching lines...) Expand all Loading... |
24 case ERR_CERT_REVOKED: | 24 case ERR_CERT_REVOKED: |
25 return CERT_STATUS_REVOKED; | 25 return CERT_STATUS_REVOKED; |
26 // We added the ERR_CERT_CONTAINS_ERRORS error code when we were using | 26 // We added the ERR_CERT_CONTAINS_ERRORS error code when we were using |
27 // WinInet, but we never figured out how it differs from ERR_CERT_INVALID. | 27 // WinInet, but we never figured out how it differs from ERR_CERT_INVALID. |
28 // We should not use ERR_CERT_CONTAINS_ERRORS in new code. | 28 // We should not use ERR_CERT_CONTAINS_ERRORS in new code. |
29 case ERR_CERT_CONTAINS_ERRORS: | 29 case ERR_CERT_CONTAINS_ERRORS: |
30 NOTREACHED(); | 30 NOTREACHED(); |
31 // Falls through. | 31 // Falls through. |
32 case ERR_CERT_INVALID: | 32 case ERR_CERT_INVALID: |
33 return CERT_STATUS_INVALID; | 33 return CERT_STATUS_INVALID; |
| 34 case ERR_CERT_WEAK_SIGNATURE_ALGORITHM: |
| 35 return CERT_STATUS_WEAK_SIGNATURE_ALGORITHM; |
34 default: | 36 default: |
35 return 0; | 37 return 0; |
36 } | 38 } |
37 } | 39 } |
38 | 40 |
39 int MapCertStatusToNetError(int cert_status) { | 41 int MapCertStatusToNetError(int cert_status) { |
40 // A certificate may have multiple errors. We report the most | 42 // A certificate may have multiple errors. We report the most |
41 // serious error. | 43 // serious error. |
42 | 44 |
43 // Unrecoverable errors | 45 // Unrecoverable errors |
44 if (cert_status & CERT_STATUS_INVALID) | 46 if (cert_status & CERT_STATUS_INVALID) |
45 return ERR_CERT_INVALID; | 47 return ERR_CERT_INVALID; |
46 if (cert_status & CERT_STATUS_REVOKED) | 48 if (cert_status & CERT_STATUS_REVOKED) |
47 return ERR_CERT_REVOKED; | 49 return ERR_CERT_REVOKED; |
48 | 50 |
49 // Recoverable errors | 51 // Recoverable errors |
50 if (cert_status & CERT_STATUS_AUTHORITY_INVALID) | 52 if (cert_status & CERT_STATUS_AUTHORITY_INVALID) |
51 return ERR_CERT_AUTHORITY_INVALID; | 53 return ERR_CERT_AUTHORITY_INVALID; |
52 if (cert_status & CERT_STATUS_COMMON_NAME_INVALID) | 54 if (cert_status & CERT_STATUS_COMMON_NAME_INVALID) |
53 return ERR_CERT_COMMON_NAME_INVALID; | 55 return ERR_CERT_COMMON_NAME_INVALID; |
| 56 if (cert_status & CERT_STATUS_WEAK_SIGNATURE_ALGORITHM) |
| 57 return ERR_CERT_WEAK_SIGNATURE_ALGORITHM; |
54 if (cert_status & CERT_STATUS_DATE_INVALID) | 58 if (cert_status & CERT_STATUS_DATE_INVALID) |
55 return ERR_CERT_DATE_INVALID; | 59 return ERR_CERT_DATE_INVALID; |
56 | 60 |
57 // Unknown status. Give it the benefit of the doubt. | 61 // Unknown status. Give it the benefit of the doubt. |
58 if (cert_status & CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) | 62 if (cert_status & CERT_STATUS_UNABLE_TO_CHECK_REVOCATION) |
59 return ERR_CERT_UNABLE_TO_CHECK_REVOCATION; | 63 return ERR_CERT_UNABLE_TO_CHECK_REVOCATION; |
60 if (cert_status & CERT_STATUS_NO_REVOCATION_MECHANISM) | 64 if (cert_status & CERT_STATUS_NO_REVOCATION_MECHANISM) |
61 return ERR_CERT_NO_REVOCATION_MECHANISM; | 65 return ERR_CERT_NO_REVOCATION_MECHANISM; |
62 | 66 |
63 NOTREACHED(); | 67 NOTREACHED(); |
64 return ERR_UNEXPECTED; | 68 return ERR_UNEXPECTED; |
65 } | 69 } |
66 | 70 |
67 } // namespace net | 71 } // namespace net |
OLD | NEW |