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 "chrome/common/net/x509_certificate_model.h" | 5 #include "chrome/common/net/x509_certificate_model.h" |
6 | 6 |
7 #include <openssl/obj_mac.h> | 7 #include <openssl/obj_mac.h> |
8 #include <openssl/sha.h> | 8 #include <openssl/sha.h> |
9 #include <openssl/x509v3.h> | 9 #include <openssl/x509v3.h> |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... | |
37 return ret; | 37 return ret; |
38 } | 38 } |
39 | 39 |
40 } // namespace | 40 } // namespace |
41 | 41 |
42 namespace x509_certificate_model { | 42 namespace x509_certificate_model { |
43 | 43 |
44 using net::X509Certificate; | 44 using net::X509Certificate; |
45 | 45 |
46 std::string GetCertNameOrNickname(X509Certificate::OSCertHandle cert_handle) { | 46 std::string GetCertNameOrNickname(X509Certificate::OSCertHandle cert_handle) { |
47 // TODO(bulach): implement me. | 47 std::string name = |
48 return ""; | 48 ProcessIDN(GetSubjectCommonName(cert_handle, std::string())); |
49 if (!name.empty()) | |
50 return name; | |
51 | |
52 char buf[256]; | |
53 if (X509_NAME_oneline(X509_get_subject_name(cert_handle), buf, sizeof(buf))) | |
Ryan Sleevi
2014/05/15 05:53:05
1) X509_NAME_online is deprecated and has been for
mattm
2014/05/20 06:29:32
Done.
| |
54 return buf; | |
55 | |
56 return std::string(); | |
49 } | 57 } |
50 | 58 |
51 std::string GetTokenName(X509Certificate::OSCertHandle cert_handle) { | 59 std::string GetTokenName(X509Certificate::OSCertHandle cert_handle) { |
52 // TODO(bulach): implement me. | 60 // TODO(bulach): implement me. |
53 return ""; | 61 return ""; |
54 } | 62 } |
55 | 63 |
56 std::string GetVersion(net::X509Certificate::OSCertHandle cert_handle) { | 64 std::string GetVersion(net::X509Certificate::OSCertHandle cert_handle) { |
57 unsigned long version = X509_get_version(cert_handle); | 65 unsigned long version = X509_get_version(cert_handle); |
58 if (version != ULONG_MAX) | 66 if (version != ULONG_MAX) |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
133 return AlternativeWhenEmpty(ret, alternative_text); | 141 return AlternativeWhenEmpty(ret, alternative_text); |
134 } | 142 } |
135 | 143 |
136 bool GetTimes(X509Certificate::OSCertHandle cert_handle, | 144 bool GetTimes(X509Certificate::OSCertHandle cert_handle, |
137 base::Time* issued, base::Time* expires) { | 145 base::Time* issued, base::Time* expires) { |
138 return x509_util::ParseDate(X509_get_notBefore(cert_handle), issued) && | 146 return x509_util::ParseDate(X509_get_notBefore(cert_handle), issued) && |
139 x509_util::ParseDate(X509_get_notAfter(cert_handle), expires); | 147 x509_util::ParseDate(X509_get_notAfter(cert_handle), expires); |
140 } | 148 } |
141 | 149 |
142 std::string GetTitle(net::X509Certificate::OSCertHandle cert_handle) { | 150 std::string GetTitle(net::X509Certificate::OSCertHandle cert_handle) { |
143 // TODO(bulach): implement me. | 151 // TODO(mattm): merge GetTitle and GetCertNameOrNickname? |
144 return ""; | 152 // Is there any reason GetCertNameOrNickname calls ProcessIDN and this |
153 // doesn't? | |
154 std::string title = | |
155 GetSubjectCommonName(cert_handle, std::string()); | |
156 if (!title.empty()) | |
157 return title; | |
158 | |
159 char buf[256]; | |
160 if (X509_NAME_oneline(X509_get_subject_name(cert_handle), buf, sizeof(buf))) | |
161 return buf; | |
162 | |
163 return std::string(); | |
145 } | 164 } |
146 | 165 |
147 std::string GetIssuerName(net::X509Certificate::OSCertHandle cert_handle) { | 166 std::string GetIssuerName(net::X509Certificate::OSCertHandle cert_handle) { |
148 return GetKeyValuesFromName(X509_get_issuer_name(cert_handle)); | 167 return GetKeyValuesFromName(X509_get_issuer_name(cert_handle)); |
149 } | 168 } |
150 | 169 |
151 std::string GetSubjectName(net::X509Certificate::OSCertHandle cert_handle) { | 170 std::string GetSubjectName(net::X509Certificate::OSCertHandle cert_handle) { |
152 return GetKeyValuesFromName(X509_get_subject_name(cert_handle)); | 171 return GetKeyValuesFromName(X509_get_subject_name(cert_handle)); |
153 } | 172 } |
154 | 173 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
226 return ""; | 245 return ""; |
227 } | 246 } |
228 | 247 |
229 std::string ProcessRawBitsSignatureWrap( | 248 std::string ProcessRawBitsSignatureWrap( |
230 net::X509Certificate::OSCertHandle cert_handle) { | 249 net::X509Certificate::OSCertHandle cert_handle) { |
231 // TODO(bulach): implement me. | 250 // TODO(bulach): implement me. |
232 return ""; | 251 return ""; |
233 } | 252 } |
234 | 253 |
235 } // namespace x509_certificate_model | 254 } // namespace x509_certificate_model |
OLD | NEW |