OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/ui/webui/certificate_viewer_webui.h" | 5 #include "chrome/browser/ui/webui/certificate_viewer_webui.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
12 #include "base/i18n/time_formatting.h" | 12 #include "base/i18n/time_formatting.h" |
13 #include "base/json/json_writer.h" | 13 #include "base/json/json_writer.h" |
14 #include "base/macros.h" | |
14 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
15 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
17 #include "base/strings/string_piece.h" | |
16 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
19 #include "base/values.h" | |
17 #include "chrome/browser/certificate_viewer.h" | 20 #include "chrome/browser/certificate_viewer.h" |
18 #include "chrome/browser/platform_util.h" | 21 #include "chrome/browser/platform_util.h" |
19 #include "chrome/browser/ui/browser_dialogs.h" | 22 #include "chrome/browser/ui/browser_dialogs.h" |
20 #include "chrome/browser/ui/certificate_dialogs.h" | 23 #include "chrome/browser/ui/certificate_dialogs.h" |
21 #include "chrome/browser/ui/webui/certificate_viewer_ui.h" | 24 #include "chrome/browser/ui/webui/certificate_viewer_ui.h" |
22 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" | 25 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" |
23 #include "chrome/common/net/x509_certificate_model.h" | 26 #include "chrome/common/net/x509_certificate_model.h" |
24 #include "chrome/common/url_constants.h" | 27 #include "chrome/common/url_constants.h" |
25 #include "chrome/grit/generated_resources.h" | 28 #include "chrome/grit/generated_resources.h" |
26 #include "content/public/browser/web_contents.h" | 29 #include "content/public/browser/web_contents.h" |
27 #include "ui/base/l10n/l10n_util.h" | 30 #include "ui/base/l10n/l10n_util.h" |
28 #include "ui/gfx/geometry/size.h" | 31 #include "ui/gfx/geometry/size.h" |
29 | 32 |
30 using content::WebContents; | 33 using content::WebContents; |
31 using content::WebUIMessageHandler; | 34 using content::WebUIMessageHandler; |
32 | 35 |
36 namespace { | |
37 | |
38 // Helper class for building a Value representation of a certificate. The class | |
39 // gathers data for a single node of the representation tree and builds a | |
40 // DictionaryValue out of that. | |
41 class CertNodeBuilder { | |
42 public: | |
43 // Starts the node with "label" set to |label|. | |
44 explicit CertNodeBuilder(base::StringPiece label); | |
45 | |
46 // Convenience version: Converts |label_id| to the corresponding resource | |
47 // string, then delegates to the other constructor. | |
48 explicit CertNodeBuilder(int label_id); | |
49 | |
50 // Builder methods all return |*this| so that they can be chained in single | |
51 // expressions. | |
52 | |
53 // Sets the "payload.val" field. Call this at most once. | |
54 CertNodeBuilder& Payload(base::StringPiece payload); | |
55 | |
56 // Adds |child| in the list keyed "children". Can be called multiple times. | |
57 CertNodeBuilder& Child(std::unique_ptr<base::DictionaryValue> child); | |
58 | |
59 // Similar to Child, but if the argument is null, then this does not add | |
60 // anything. | |
61 CertNodeBuilder& ChildIfNotNull(std::unique_ptr<base::DictionaryValue> child); | |
62 | |
63 // Creates a DictionaryValue representation of the collected information. Only | |
64 // call this once. | |
65 std::unique_ptr<base::DictionaryValue> Build(); | |
66 | |
67 private: | |
68 base::DictionaryValue node_; | |
69 base::ListValue children_; | |
70 // |built_| is false until Build() is called. Once it is |true|, |node_| and | |
71 // |children_| are no longer valid for use. | |
72 bool built_ = false; | |
73 | |
74 DISALLOW_COPY_AND_ASSIGN(CertNodeBuilder); | |
75 }; | |
76 | |
77 CertNodeBuilder::CertNodeBuilder(base::StringPiece label) { | |
78 node_.SetString("label", label); | |
79 } | |
80 | |
81 CertNodeBuilder::CertNodeBuilder(int label_id) | |
82 : CertNodeBuilder(l10n_util::GetStringUTF8(label_id)) {} | |
83 | |
84 CertNodeBuilder& CertNodeBuilder::Payload(base::StringPiece payload) { | |
85 DCHECK(!node_.HasKey("payload.val")); | |
86 node_.SetString("payload.val", payload); | |
87 return *this; | |
88 } | |
89 | |
90 CertNodeBuilder& CertNodeBuilder::Child( | |
91 std::unique_ptr<base::DictionaryValue> child) { | |
92 children_.Append(std::move(child)); | |
93 return *this; | |
94 } | |
95 | |
96 CertNodeBuilder& CertNodeBuilder::ChildIfNotNull( | |
97 std::unique_ptr<base::DictionaryValue> child) { | |
98 if (child) | |
99 return Child(std::move(child)); | |
100 return *this; | |
101 } | |
102 | |
103 std::unique_ptr<base::DictionaryValue> CertNodeBuilder::Build() { | |
104 DCHECK(!built_); | |
105 if (!children_.empty()) { | |
106 node_.Set("children", base::MakeUnique<base::Value>(std::move(children_))); | |
107 } | |
108 built_ = true; | |
109 return base::DictionaryValue::From( | |
110 base::MakeUnique<base::Value>(std::move(node_))); | |
michaelpg
2017/04/13 01:07:00
jdoerrie, correct me if I'm wrong, but could this
vabr (Chromium)
2017/04/13 06:20:26
Thanks for catching this! You are correct, I someh
jdoerrie
2017/04/13 08:38:42
Yes, you are right michaelpg@. Vaclav's updated ch
| |
111 } | |
112 | |
113 } // namespace | |
114 | |
33 // Shows a certificate using the WebUI certificate viewer. | 115 // Shows a certificate using the WebUI certificate viewer. |
34 void ShowCertificateViewer(WebContents* web_contents, | 116 void ShowCertificateViewer(WebContents* web_contents, |
35 gfx::NativeWindow parent, | 117 gfx::NativeWindow parent, |
36 net::X509Certificate* cert) { | 118 net::X509Certificate* cert) { |
37 CertificateViewerDialog* dialog = new CertificateViewerDialog(cert); | 119 CertificateViewerDialog* dialog = new CertificateViewerDialog(cert); |
38 dialog->Show(web_contents, parent); | 120 dialog->Show(web_contents, parent); |
39 } | 121 } |
40 | 122 |
41 //////////////////////////////////////////////////////////////////////////////// | 123 //////////////////////////////////////////////////////////////////////////////// |
42 // CertificateViewerDialog | 124 // CertificateViewerDialog |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
162 } | 244 } |
163 cert_info.SetString("general.issue-date", issued_str); | 245 cert_info.SetString("general.issue-date", issued_str); |
164 cert_info.SetString("general.expiry-date", expires_str); | 246 cert_info.SetString("general.expiry-date", expires_str); |
165 | 247 |
166 cert_info.SetString("general.sha256", | 248 cert_info.SetString("general.sha256", |
167 x509_certificate_model::HashCertSHA256(cert_hnd)); | 249 x509_certificate_model::HashCertSHA256(cert_hnd)); |
168 cert_info.SetString("general.sha1", | 250 cert_info.SetString("general.sha1", |
169 x509_certificate_model::HashCertSHA1(cert_hnd)); | 251 x509_certificate_model::HashCertSHA1(cert_hnd)); |
170 | 252 |
171 // Certificate hierarchy is constructed from bottom up. | 253 // Certificate hierarchy is constructed from bottom up. |
172 base::ListValue* children = NULL; | 254 std::unique_ptr<base::ListValue> children; |
173 int index = 0; | 255 int index = 0; |
174 for (net::X509Certificate::OSCertHandles::const_iterator i = | 256 for (net::X509Certificate::OSCertHandles::const_iterator i = |
175 cert_chain.begin(); i != cert_chain.end(); ++i, ++index) { | 257 cert_chain.begin(); i != cert_chain.end(); ++i, ++index) { |
176 std::unique_ptr<base::DictionaryValue> cert_node( | 258 std::unique_ptr<base::DictionaryValue> cert_node( |
177 new base::DictionaryValue()); | 259 new base::DictionaryValue()); |
178 base::ListValue cert_details; | 260 base::ListValue cert_details; |
179 cert_node->SetString("label", x509_certificate_model::GetTitle(*i).c_str()); | 261 cert_node->SetString("label", x509_certificate_model::GetTitle(*i).c_str()); |
180 cert_node->SetDouble("payload.index", index); | 262 cert_node->SetDouble("payload.index", index); |
181 // Add the child from the previous iteration. | 263 // Add the child from the previous iteration. |
182 if (children) | 264 if (children) |
183 cert_node->Set("children", children); | 265 cert_node->Set("children", std::move(children)); |
184 | 266 |
185 // Add this node to the children list for the next iteration. | 267 // Add this node to the children list for the next iteration. |
186 children = new base::ListValue(); | 268 children = base::MakeUnique<base::ListValue>(); |
187 children->Append(std::move(cert_node)); | 269 children->Append(std::move(cert_node)); |
188 } | 270 } |
189 // Set the last node as the top of the certificate hierarchy. | 271 // Set the last node as the top of the certificate hierarchy. |
190 cert_info.Set("hierarchy", children); | 272 cert_info.Set("hierarchy", std::move(children)); |
191 | 273 |
192 base::JSONWriter::Write(cert_info, &data); | 274 base::JSONWriter::Write(cert_info, &data); |
193 | 275 |
194 return data; | 276 return data; |
195 } | 277 } |
196 | 278 |
197 void CertificateViewerModalDialog::OnDialogShown( | 279 void CertificateViewerModalDialog::OnDialogShown( |
198 content::WebUI* webui, | 280 content::WebUI* webui, |
199 content::RenderViewHost* render_view_host) { | 281 content::RenderViewHost* render_view_host) { |
200 webui_ = webui; | 282 webui_ = webui; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
276 return; | 358 return; |
277 | 359 |
278 gfx::NativeWindow window = | 360 gfx::NativeWindow window = |
279 platform_util::GetTopLevel(dialog_->GetNativeWebContentsModalDialog()); | 361 platform_util::GetTopLevel(dialog_->GetNativeWebContentsModalDialog()); |
280 ShowCertExportDialog(web_ui()->GetWebContents(), | 362 ShowCertExportDialog(web_ui()->GetWebContents(), |
281 window, | 363 window, |
282 cert_chain_.begin() + cert_index, | 364 cert_chain_.begin() + cert_index, |
283 cert_chain_.end()); | 365 cert_chain_.end()); |
284 } | 366 } |
285 | 367 |
286 void CertificateViewerDialogHandler::RequestCertificateFields( | 368 void CertificateViewerDialogHandler::RequestCertificateFields( |
michaelpg
2017/04/13 01:07:00
In the CL title and description, did you mean to r
michaelpg
2017/04/13 19:38:35
ping ^
vabr (Chromium)
2017/04/14 07:59:04
Indeed, thanks for catching that!
| |
287 const base::ListValue* args) { | 369 const base::ListValue* args) { |
288 int cert_index = GetCertificateIndex(args); | 370 int cert_index = GetCertificateIndex(args); |
289 if (cert_index < 0) | 371 if (cert_index < 0) |
290 return; | 372 return; |
291 | 373 |
292 net::X509Certificate::OSCertHandle cert = cert_chain_[cert_index]; | 374 net::X509Certificate::OSCertHandle cert = cert_chain_[cert_index]; |
293 | 375 |
294 // Main certificate fields. | 376 CertNodeBuilder version_node(IDS_CERT_DETAILS_VERSION); |
295 auto cert_fields = base::MakeUnique<base::ListValue>(); | |
296 auto node_details = base::MakeUnique<base::DictionaryValue>(); | |
297 node_details->SetString("label", | |
298 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_VERSION)); | |
299 std::string version = x509_certificate_model::GetVersion(cert); | 377 std::string version = x509_certificate_model::GetVersion(cert); |
300 if (!version.empty()) { | 378 if (!version.empty()) { |
301 node_details->SetString("payload.val", | 379 version_node.Payload(l10n_util::GetStringFUTF8( |
302 l10n_util::GetStringFUTF8(IDS_CERT_DETAILS_VERSION_FORMAT, | 380 IDS_CERT_DETAILS_VERSION_FORMAT, base::UTF8ToUTF16(version))); |
303 base::UTF8ToUTF16(version))); | |
304 } | 381 } |
305 cert_fields->Append(std::move(node_details)); | |
306 | 382 |
307 node_details = base::MakeUnique<base::DictionaryValue>(); | 383 CertNodeBuilder issued_node_builder(IDS_CERT_DETAILS_NOT_BEFORE); |
308 node_details->SetString("label", | 384 CertNodeBuilder expires_node_builder(IDS_CERT_DETAILS_NOT_AFTER); |
309 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_SERIAL_NUMBER)); | |
310 node_details->SetString("payload.val", | |
311 x509_certificate_model::GetSerialNumberHexified(cert, | |
312 l10n_util::GetStringUTF8(IDS_CERT_INFO_FIELD_NOT_PRESENT))); | |
313 cert_fields->Append(std::move(node_details)); | |
314 | |
315 node_details = base::MakeUnique<base::DictionaryValue>(); | |
316 node_details->SetString("label", | |
317 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_CERTIFICATE_SIG_ALG)); | |
318 node_details->SetString("payload.val", | |
319 x509_certificate_model::ProcessSecAlgorithmSignature(cert)); | |
320 cert_fields->Append(std::move(node_details)); | |
321 | |
322 node_details = base::MakeUnique<base::DictionaryValue>(); | |
323 node_details->SetString("label", | |
324 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_ISSUER)); | |
325 node_details->SetString("payload.val", | |
326 x509_certificate_model::GetIssuerName(cert)); | |
327 cert_fields->Append(std::move(node_details)); | |
328 | |
329 // Validity period. | |
330 auto cert_sub_fields = base::MakeUnique<base::ListValue>(); | |
331 | |
332 auto sub_node_details = base::MakeUnique<base::DictionaryValue>(); | |
333 sub_node_details->SetString( | |
334 "label", l10n_util::GetStringUTF8(IDS_CERT_DETAILS_NOT_BEFORE)); | |
335 | |
336 auto alt_node_details = base::MakeUnique<base::DictionaryValue>(); | |
337 alt_node_details->SetString("label", | |
338 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_NOT_AFTER)); | |
339 | |
340 base::Time issued, expires; | 385 base::Time issued, expires; |
341 if (x509_certificate_model::GetTimes(cert, &issued, &expires)) { | 386 if (x509_certificate_model::GetTimes(cert, &issued, &expires)) { |
342 sub_node_details->SetString( | 387 issued_node_builder.Payload(base::UTF16ToUTF8( |
343 "payload.val", | 388 base::TimeFormatShortDateAndTimeWithTimeZone(issued))); |
344 base::UTF16ToUTF8( | 389 expires_node_builder.Payload(base::UTF16ToUTF8( |
345 base::TimeFormatShortDateAndTimeWithTimeZone(issued))); | 390 base::TimeFormatShortDateAndTimeWithTimeZone(expires))); |
346 alt_node_details->SetString( | |
347 "payload.val", | |
348 base::UTF16ToUTF8( | |
349 base::TimeFormatShortDateAndTimeWithTimeZone(expires))); | |
350 } | 391 } |
351 cert_sub_fields->Append(std::move(sub_node_details)); | |
352 cert_sub_fields->Append(std::move(alt_node_details)); | |
353 | 392 |
354 node_details = base::MakeUnique<base::DictionaryValue>(); | |
355 node_details->SetString("label", | |
356 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_VALIDITY)); | |
357 node_details->Set("children", std::move(cert_sub_fields)); | |
358 cert_fields->Append(std::move(node_details)); | |
359 | |
360 node_details = base::MakeUnique<base::DictionaryValue>(); | |
361 node_details->SetString("label", | |
362 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_SUBJECT)); | |
363 node_details->SetString("payload.val", | |
364 x509_certificate_model::GetSubjectName(cert)); | |
365 cert_fields->Append(std::move(node_details)); | |
366 | |
367 // Subject key information. | |
368 cert_sub_fields = base::MakeUnique<base::ListValue>(); | |
369 | |
370 sub_node_details = base::MakeUnique<base::DictionaryValue>(); | |
371 sub_node_details->SetString( | |
372 "label", l10n_util::GetStringUTF8(IDS_CERT_DETAILS_SUBJECT_KEY_ALG)); | |
373 sub_node_details->SetString( | |
374 "payload.val", | |
375 x509_certificate_model::ProcessSecAlgorithmSubjectPublicKey(cert)); | |
376 cert_sub_fields->Append(std::move(sub_node_details)); | |
377 | |
378 sub_node_details = base::MakeUnique<base::DictionaryValue>(); | |
379 sub_node_details->SetString( | |
380 "label", l10n_util::GetStringUTF8(IDS_CERT_DETAILS_SUBJECT_KEY)); | |
381 sub_node_details->SetString( | |
382 "payload.val", x509_certificate_model::ProcessSubjectPublicKeyInfo(cert)); | |
383 cert_sub_fields->Append(std::move(sub_node_details)); | |
384 | |
385 node_details = base::MakeUnique<base::DictionaryValue>(); | |
386 node_details->SetString( | |
387 "label", l10n_util::GetStringUTF8(IDS_CERT_DETAILS_SUBJECT_KEY_INFO)); | |
388 node_details->Set("children", std::move(cert_sub_fields)); | |
389 cert_fields->Append(std::move(node_details)); | |
390 | |
391 // Extensions. | |
392 x509_certificate_model::Extensions extensions; | 393 x509_certificate_model::Extensions extensions; |
393 x509_certificate_model::GetExtensions( | 394 x509_certificate_model::GetExtensions( |
394 l10n_util::GetStringUTF8(IDS_CERT_EXTENSION_CRITICAL), | 395 l10n_util::GetStringUTF8(IDS_CERT_EXTENSION_CRITICAL), |
395 l10n_util::GetStringUTF8(IDS_CERT_EXTENSION_NON_CRITICAL), | 396 l10n_util::GetStringUTF8(IDS_CERT_EXTENSION_NON_CRITICAL), |
396 cert, &extensions); | 397 cert, &extensions); |
397 | 398 |
399 std::unique_ptr<base::DictionaryValue> details_extensions; | |
398 if (!extensions.empty()) { | 400 if (!extensions.empty()) { |
399 cert_sub_fields = base::MakeUnique<base::ListValue>(); | 401 CertNodeBuilder details_extensions_builder(IDS_CERT_DETAILS_EXTENSIONS); |
400 | 402 for (const x509_certificate_model::Extension& extension : extensions) { |
401 for (x509_certificate_model::Extensions::const_iterator i = | 403 details_extensions_builder.Child( |
402 extensions.begin(); i != extensions.end(); ++i) { | 404 CertNodeBuilder(extension.name).Payload(extension.value).Build()); |
403 sub_node_details = base::MakeUnique<base::DictionaryValue>(); | |
404 sub_node_details->SetString("label", i->name); | |
405 sub_node_details->SetString("payload.val", i->value); | |
406 cert_sub_fields->Append(std::move(sub_node_details)); | |
407 } | 405 } |
408 | 406 details_extensions = details_extensions_builder.Build(); |
409 node_details = base::MakeUnique<base::DictionaryValue>(); | |
410 node_details->SetString( | |
411 "label", l10n_util::GetStringUTF8(IDS_CERT_DETAILS_EXTENSIONS)); | |
412 node_details->Set("children", std::move(cert_sub_fields)); | |
413 cert_fields->Append(std::move(node_details)); | |
414 } | 407 } |
415 | 408 |
416 // Details certificate information. | |
417 node_details = base::MakeUnique<base::DictionaryValue>(); | |
418 node_details->SetString("label", | |
419 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_CERTIFICATE_SIG_ALG)); | |
420 node_details->SetString("payload.val", | |
421 x509_certificate_model::ProcessSecAlgorithmSignatureWrap(cert)); | |
422 cert_fields->Append(std::move(node_details)); | |
423 | |
424 node_details = base::MakeUnique<base::DictionaryValue>(); | |
425 node_details->SetString("label", | |
426 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_CERTIFICATE_SIG_VALUE)); | |
427 node_details->SetString("payload.val", | |
428 x509_certificate_model::ProcessRawBitsSignatureWrap(cert)); | |
429 cert_fields->Append(std::move(node_details)); | |
430 | |
431 // Fingerprint information. | |
432 cert_sub_fields = base::MakeUnique<base::ListValue>(); | |
433 | |
434 sub_node_details = base::MakeUnique<base::DictionaryValue>(); | |
435 sub_node_details->SetString( | |
436 "label", | |
437 l10n_util::GetStringUTF8(IDS_CERT_INFO_SHA256_FINGERPRINT_LABEL)); | |
438 sub_node_details->SetString("payload.val", | |
439 x509_certificate_model::HashCertSHA256(cert)); | |
440 cert_sub_fields->Append(std::move(sub_node_details)); | |
441 | |
442 sub_node_details = base::MakeUnique<base::DictionaryValue>(); | |
443 sub_node_details->SetString( | |
444 "label", l10n_util::GetStringUTF8(IDS_CERT_INFO_SHA1_FINGERPRINT_LABEL)); | |
445 sub_node_details->SetString("payload.val", | |
446 x509_certificate_model::HashCertSHA1(cert)); | |
447 cert_sub_fields->Append(std::move(sub_node_details)); | |
448 | |
449 node_details = base::MakeUnique<base::DictionaryValue>(); | |
450 node_details->SetString( | |
451 "label", l10n_util::GetStringUTF8(IDS_CERT_INFO_FINGERPRINTS_GROUP)); | |
452 node_details->Set("children", std::move(cert_sub_fields)); | |
453 cert_fields->Append(std::move(node_details)); | |
454 | |
455 // Certificate information. | |
456 node_details = base::MakeUnique<base::DictionaryValue>(); | |
457 node_details->SetString( | |
458 "label", l10n_util::GetStringUTF8(IDS_CERT_DETAILS_CERTIFICATE)); | |
459 node_details->Set("children", std::move(cert_fields)); | |
460 cert_fields = base::MakeUnique<base::ListValue>(); | |
461 cert_fields->Append(std::move(node_details)); | |
462 | |
463 // Top level information. | |
464 base::ListValue root_list; | 409 base::ListValue root_list; |
465 node_details = base::MakeUnique<base::DictionaryValue>(); | 410 root_list.Append( |
466 node_details->SetString("label", x509_certificate_model::GetTitle(cert)); | 411 CertNodeBuilder(x509_certificate_model::GetTitle(cert)) |
467 node_details->Set("children", std::move(cert_fields)); | 412 .Child( |
468 root_list.Append(std::move(node_details)); | 413 CertNodeBuilder( |
414 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_CERTIFICATE)) | |
415 // Main certificate fields. | |
416 .Child(version_node.Build()) | |
417 .Child( | |
418 CertNodeBuilder(IDS_CERT_DETAILS_SERIAL_NUMBER) | |
419 .Payload( | |
420 x509_certificate_model::GetSerialNumberHexified( | |
421 cert, l10n_util::GetStringUTF8( | |
422 IDS_CERT_INFO_FIELD_NOT_PRESENT))) | |
423 .Build()) | |
424 .Child(CertNodeBuilder(IDS_CERT_DETAILS_CERTIFICATE_SIG_ALG) | |
425 .Payload(x509_certificate_model:: | |
426 ProcessSecAlgorithmSignature(cert)) | |
427 .Build()) | |
428 .Child( | |
429 CertNodeBuilder(IDS_CERT_DETAILS_ISSUER) | |
430 .Payload(x509_certificate_model::GetIssuerName(cert)) | |
431 .Build()) | |
432 // Validity period. | |
433 .Child(CertNodeBuilder(IDS_CERT_DETAILS_VALIDITY) | |
434 .Child(issued_node_builder.Build()) | |
435 .Child(expires_node_builder.Build()) | |
436 .Build()) | |
437 .Child( | |
438 CertNodeBuilder(IDS_CERT_DETAILS_SUBJECT) | |
439 .Payload(x509_certificate_model::GetSubjectName(cert)) | |
440 .Build()) | |
441 // Subject key information. | |
442 .Child( | |
443 CertNodeBuilder(IDS_CERT_DETAILS_SUBJECT_KEY_INFO) | |
444 .Child( | |
445 CertNodeBuilder(IDS_CERT_DETAILS_SUBJECT_KEY_ALG) | |
446 .Payload( | |
447 x509_certificate_model:: | |
448 ProcessSecAlgorithmSubjectPublicKey( | |
449 cert)) | |
450 .Build()) | |
451 .Child(CertNodeBuilder(IDS_CERT_DETAILS_SUBJECT_KEY) | |
452 .Payload( | |
453 x509_certificate_model:: | |
454 ProcessSubjectPublicKeyInfo(cert)) | |
455 .Build()) | |
456 .Build()) | |
457 // Extensions. | |
458 .ChildIfNotNull(std::move(details_extensions)) | |
459 .Child( | |
460 CertNodeBuilder(IDS_CERT_DETAILS_CERTIFICATE_SIG_ALG) | |
461 .Payload(x509_certificate_model:: | |
462 ProcessSecAlgorithmSignatureWrap(cert)) | |
463 .Build()) | |
464 .Child(CertNodeBuilder(IDS_CERT_DETAILS_CERTIFICATE_SIG_VALUE) | |
465 .Payload(x509_certificate_model:: | |
466 ProcessRawBitsSignatureWrap(cert)) | |
467 .Build()) | |
468 .Child( | |
469 CertNodeBuilder(IDS_CERT_INFO_FINGERPRINTS_GROUP) | |
470 .Child(CertNodeBuilder( | |
471 IDS_CERT_INFO_SHA256_FINGERPRINT_LABEL) | |
472 .Payload( | |
473 x509_certificate_model::HashCertSHA256( | |
474 cert)) | |
475 .Build()) | |
476 .Child( | |
477 CertNodeBuilder( | |
478 IDS_CERT_INFO_SHA1_FINGERPRINT_LABEL) | |
479 .Payload(x509_certificate_model::HashCertSHA1( | |
480 cert)) | |
481 .Build()) | |
482 .Build()) | |
483 .Build()) | |
484 .Build()); | |
michaelpg
2017/04/13 01:07:00
If you like, we could remove all these .Build() bo
vabr (Chromium)
2017/04/14 07:59:04
I like this, but the style guide forbids passing n
michaelpg
2017/04/14 18:08:31
yeah, any way I can think of would violate some st
| |
469 | 485 |
470 // Send certificate information to javascript. | 486 // Send certificate information to javascript. |
471 web_ui()->CallJavascriptFunctionUnsafe("cert_viewer.getCertificateFields", | 487 web_ui()->CallJavascriptFunctionUnsafe("cert_viewer.getCertificateFields", |
472 root_list); | 488 root_list); |
473 } | 489 } |
474 | 490 |
475 int CertificateViewerDialogHandler::GetCertificateIndex( | 491 int CertificateViewerDialogHandler::GetCertificateIndex( |
476 const base::ListValue* args) const { | 492 const base::ListValue* args) const { |
477 int cert_index; | 493 int cert_index; |
478 double val; | 494 double val; |
479 if (!(args->GetDouble(0, &val))) | 495 if (!(args->GetDouble(0, &val))) |
480 return -1; | 496 return -1; |
481 cert_index = static_cast<int>(val); | 497 cert_index = static_cast<int>(val); |
482 if (cert_index < 0 || cert_index >= static_cast<int>(cert_chain_.size())) | 498 if (cert_index < 0 || cert_index >= static_cast<int>(cert_chain_.size())) |
483 return -1; | 499 return -1; |
484 return cert_index; | 500 return cert_index; |
485 } | 501 } |
OLD | NEW |