OLD | NEW |
1 /* ***** BEGIN LICENSE BLOCK ***** | 1 /* ***** BEGIN LICENSE BLOCK ***** |
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
3 * | 3 * |
4 * The contents of this file are subject to the Mozilla Public License Version | 4 * The contents of this file are subject to the Mozilla Public License Version |
5 * 1.1 (the "License"); you may not use this file except in compliance with | 5 * 1.1 (the "License"); you may not use this file except in compliance with |
6 * the License. You may obtain a copy of the License at | 6 * the License. You may obtain a copy of the License at |
7 * http://www.mozilla.org/MPL/ | 7 * http://www.mozilla.org/MPL/ |
8 * | 8 * |
9 * Software distributed under the License is distributed on an "AS IS" basis, | 9 * Software distributed under the License is distributed on an "AS IS" basis, |
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | 10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
(...skipping 22 matching lines...) Expand all Loading... |
33 * use your version of this file under the terms of the MPL, indicate your | 33 * use your version of this file under the terms of the MPL, indicate your |
34 * decision by deleting the provisions above and replace them with the notice | 34 * decision by deleting the provisions above and replace them with the notice |
35 * and other provisions required by the GPL or the LGPL. If you do not delete | 35 * and other provisions required by the GPL or the LGPL. If you do not delete |
36 * the provisions above, a recipient may use your version of this file under | 36 * the provisions above, a recipient may use your version of this file under |
37 * the terms of any one of the MPL, the GPL or the LGPL. | 37 * the terms of any one of the MPL, the GPL or the LGPL. |
38 * | 38 * |
39 * ***** END LICENSE BLOCK ***** */ | 39 * ***** END LICENSE BLOCK ***** */ |
40 | 40 |
41 #include "chrome/third_party/mozilla_security_manager/nsNSSCertHelper.h" | 41 #include "chrome/third_party/mozilla_security_manager/nsNSSCertHelper.h" |
42 | 42 |
| 43 #include <certdb.h> |
43 #include <keyhi.h> | 44 #include <keyhi.h> |
44 #include <prprf.h> | 45 #include <prprf.h> |
45 #include <unicode/uidna.h> | 46 #include <unicode/uidna.h> |
46 | 47 |
47 #include "base/i18n/number_formatting.h" | 48 #include "base/i18n/number_formatting.h" |
48 #include "base/string_number_conversions.h" | 49 #include "base/string_number_conversions.h" |
49 #include "base/stringprintf.h" | 50 #include "base/stringprintf.h" |
50 #include "base/utf_string_conversions.h" | 51 #include "base/utf_string_conversions.h" |
51 #include "chrome/common/net/x509_certificate_model.h" | 52 #include "chrome/common/net/x509_certificate_model.h" |
52 #include "crypto/scoped_nss_types.h" | 53 #include "crypto/scoped_nss_types.h" |
53 #include "grit/generated_resources.h" | 54 #include "grit/generated_resources.h" |
54 #include "net/base/ip_endpoint.h" | 55 #include "net/base/ip_endpoint.h" |
55 #include "net/base/net_util.h" | 56 #include "net/base/net_util.h" |
56 #include "net/third_party/mozilla_security_manager/nsNSSCertTrust.h" | |
57 #include "ui/base/l10n/l10n_util.h" | 57 #include "ui/base/l10n/l10n_util.h" |
58 | 58 |
| 59 #if !defined(CERTDB_TERMINAL_RECORD) |
| 60 /* NSS 3.13 renames CERTDB_VALID_PEER to CERTDB_TERMINAL_RECORD |
| 61 * and marks CERTDB_VALID_PEER as deprecated. |
| 62 * If we're using an older version, rename it ourselves. |
| 63 */ |
| 64 #define CERTDB_TERMINAL_RECORD CERTDB_VALID_PEER |
| 65 #endif |
| 66 |
59 namespace { | 67 namespace { |
60 | 68 |
61 std::string BMPtoUTF8(PRArenaPool* arena, unsigned char* data, | 69 std::string BMPtoUTF8(PRArenaPool* arena, unsigned char* data, |
62 unsigned int len) { | 70 unsigned int len) { |
63 if (len % 2 != 0) | 71 if (len % 2 != 0) |
64 return l10n_util::GetStringUTF8(IDS_CERT_EXTENSION_DUMP_ERROR); | 72 return l10n_util::GetStringUTF8(IDS_CERT_EXTENSION_DUMP_ERROR); |
65 | 73 |
66 unsigned int utf8_val_len = len * 3 + 1; | 74 unsigned int utf8_val_len = len * 3 + 1; |
67 std::vector<unsigned char> utf8_val(utf8_val_len); | 75 std::vector<unsigned char> utf8_val(utf8_val_len); |
68 if (!PORT_UCS2_UTF8Conversion(PR_FALSE, data, len, | 76 if (!PORT_UCS2_UTF8Conversion(PR_FALSE, data, len, |
(...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 rv = x509_certificate_model::ProcessRawBits( | 1039 rv = x509_certificate_model::ProcessRawBits( |
1032 spki->subjectPublicKey.data, spki->subjectPublicKey.len); | 1040 spki->subjectPublicKey.data, spki->subjectPublicKey.len); |
1033 break; | 1041 break; |
1034 } | 1042 } |
1035 SECKEY_DestroyPublicKey(key); | 1043 SECKEY_DestroyPublicKey(key); |
1036 } | 1044 } |
1037 return rv; | 1045 return rv; |
1038 } | 1046 } |
1039 | 1047 |
1040 net::CertType GetCertType(CERTCertificate *cert) { | 1048 net::CertType GetCertType(CERTCertificate *cert) { |
1041 nsNSSCertTrust trust(cert->trust); | 1049 CERTCertTrust trust = {0}; |
1042 if (cert->nickname && trust.HasAnyUser()) | 1050 CERT_GetCertTrust(cert, &trust); |
| 1051 |
| 1052 unsigned all_flags = trust.sslFlags | trust.emailFlags | |
| 1053 trust.objectSigningFlags; |
| 1054 |
| 1055 if (cert->nickname && (all_flags & CERTDB_USER)) |
1043 return net::USER_CERT; | 1056 return net::USER_CERT; |
1044 if (trust.HasAnyCA() || CERT_IsCACert(cert, NULL)) | 1057 if ((all_flags & CERTDB_VALID_CA) || CERT_IsCACert(cert, NULL)) |
1045 return net::CA_CERT; | 1058 return net::CA_CERT; |
1046 if (trust.HasPeer(PR_TRUE, PR_FALSE, PR_FALSE)) | 1059 // TODO(mattm): http://crbug.com/128633. |
| 1060 if (trust.sslFlags & CERTDB_TERMINAL_RECORD) |
1047 return net::SERVER_CERT; | 1061 return net::SERVER_CERT; |
1048 return net::UNKNOWN_CERT; | 1062 return net::UNKNOWN_CERT; |
1049 } | 1063 } |
1050 | 1064 |
1051 } // namespace mozilla_security_manager | 1065 } // namespace mozilla_security_manager |
OLD | NEW |