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::MakeUnique<base::DictionaryValue>(std::move(node_)); |
| 110 } |
| 111 |
| 112 } // namespace |
| 113 |
33 // Shows a certificate using the WebUI certificate viewer. | 114 // Shows a certificate using the WebUI certificate viewer. |
34 void ShowCertificateViewer(WebContents* web_contents, | 115 void ShowCertificateViewer(WebContents* web_contents, |
35 gfx::NativeWindow parent, | 116 gfx::NativeWindow parent, |
36 net::X509Certificate* cert) { | 117 net::X509Certificate* cert) { |
37 CertificateViewerDialog* dialog = new CertificateViewerDialog(cert); | 118 CertificateViewerDialog* dialog = new CertificateViewerDialog(cert); |
38 dialog->Show(web_contents, parent); | 119 dialog->Show(web_contents, parent); |
39 } | 120 } |
40 | 121 |
41 //////////////////////////////////////////////////////////////////////////////// | 122 //////////////////////////////////////////////////////////////////////////////// |
42 // CertificateViewerDialog | 123 // CertificateViewerDialog |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 } | 243 } |
163 cert_info.SetString("general.issue-date", issued_str); | 244 cert_info.SetString("general.issue-date", issued_str); |
164 cert_info.SetString("general.expiry-date", expires_str); | 245 cert_info.SetString("general.expiry-date", expires_str); |
165 | 246 |
166 cert_info.SetString("general.sha256", | 247 cert_info.SetString("general.sha256", |
167 x509_certificate_model::HashCertSHA256(cert_hnd)); | 248 x509_certificate_model::HashCertSHA256(cert_hnd)); |
168 cert_info.SetString("general.sha1", | 249 cert_info.SetString("general.sha1", |
169 x509_certificate_model::HashCertSHA1(cert_hnd)); | 250 x509_certificate_model::HashCertSHA1(cert_hnd)); |
170 | 251 |
171 // Certificate hierarchy is constructed from bottom up. | 252 // Certificate hierarchy is constructed from bottom up. |
172 base::ListValue* children = NULL; | 253 std::unique_ptr<base::ListValue> children; |
173 int index = 0; | 254 int index = 0; |
174 for (net::X509Certificate::OSCertHandles::const_iterator i = | 255 for (net::X509Certificate::OSCertHandles::const_iterator i = |
175 cert_chain.begin(); i != cert_chain.end(); ++i, ++index) { | 256 cert_chain.begin(); i != cert_chain.end(); ++i, ++index) { |
176 std::unique_ptr<base::DictionaryValue> cert_node( | 257 std::unique_ptr<base::DictionaryValue> cert_node( |
177 new base::DictionaryValue()); | 258 new base::DictionaryValue()); |
178 base::ListValue cert_details; | 259 base::ListValue cert_details; |
179 cert_node->SetString("label", x509_certificate_model::GetTitle(*i).c_str()); | 260 cert_node->SetString("label", x509_certificate_model::GetTitle(*i).c_str()); |
180 cert_node->SetDouble("payload.index", index); | 261 cert_node->SetDouble("payload.index", index); |
181 // Add the child from the previous iteration. | 262 // Add the child from the previous iteration. |
182 if (children) | 263 if (children) |
183 cert_node->Set("children", children); | 264 cert_node->Set("children", std::move(children)); |
184 | 265 |
185 // Add this node to the children list for the next iteration. | 266 // Add this node to the children list for the next iteration. |
186 children = new base::ListValue(); | 267 children = base::MakeUnique<base::ListValue>(); |
187 children->Append(std::move(cert_node)); | 268 children->Append(std::move(cert_node)); |
188 } | 269 } |
189 // Set the last node as the top of the certificate hierarchy. | 270 // Set the last node as the top of the certificate hierarchy. |
190 cert_info.Set("hierarchy", children); | 271 cert_info.Set("hierarchy", std::move(children)); |
191 | 272 |
192 base::JSONWriter::Write(cert_info, &data); | 273 base::JSONWriter::Write(cert_info, &data); |
193 | 274 |
194 return data; | 275 return data; |
195 } | 276 } |
196 | 277 |
197 void CertificateViewerModalDialog::OnDialogShown( | 278 void CertificateViewerModalDialog::OnDialogShown( |
198 content::WebUI* webui, | 279 content::WebUI* webui, |
199 content::RenderViewHost* render_view_host) { | 280 content::RenderViewHost* render_view_host) { |
200 webui_ = webui; | 281 webui_ = webui; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 } | 365 } |
285 | 366 |
286 void CertificateViewerDialogHandler::RequestCertificateFields( | 367 void CertificateViewerDialogHandler::RequestCertificateFields( |
287 const base::ListValue* args) { | 368 const base::ListValue* args) { |
288 int cert_index = GetCertificateIndex(args); | 369 int cert_index = GetCertificateIndex(args); |
289 if (cert_index < 0) | 370 if (cert_index < 0) |
290 return; | 371 return; |
291 | 372 |
292 net::X509Certificate::OSCertHandle cert = cert_chain_[cert_index]; | 373 net::X509Certificate::OSCertHandle cert = cert_chain_[cert_index]; |
293 | 374 |
294 // Main certificate fields. | 375 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); | 376 std::string version = x509_certificate_model::GetVersion(cert); |
300 if (!version.empty()) { | 377 if (!version.empty()) { |
301 node_details->SetString("payload.val", | 378 version_node.Payload(l10n_util::GetStringFUTF8( |
302 l10n_util::GetStringFUTF8(IDS_CERT_DETAILS_VERSION_FORMAT, | 379 IDS_CERT_DETAILS_VERSION_FORMAT, base::UTF8ToUTF16(version))); |
303 base::UTF8ToUTF16(version))); | |
304 } | 380 } |
305 cert_fields->Append(std::move(node_details)); | |
306 | 381 |
307 node_details = base::MakeUnique<base::DictionaryValue>(); | 382 CertNodeBuilder issued_node_builder(IDS_CERT_DETAILS_NOT_BEFORE); |
308 node_details->SetString("label", | 383 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; | 384 base::Time issued, expires; |
341 if (x509_certificate_model::GetTimes(cert, &issued, &expires)) { | 385 if (x509_certificate_model::GetTimes(cert, &issued, &expires)) { |
342 sub_node_details->SetString( | 386 issued_node_builder.Payload(base::UTF16ToUTF8( |
343 "payload.val", | 387 base::TimeFormatShortDateAndTimeWithTimeZone(issued))); |
344 base::UTF16ToUTF8( | 388 expires_node_builder.Payload(base::UTF16ToUTF8( |
345 base::TimeFormatShortDateAndTimeWithTimeZone(issued))); | 389 base::TimeFormatShortDateAndTimeWithTimeZone(expires))); |
346 alt_node_details->SetString( | |
347 "payload.val", | |
348 base::UTF16ToUTF8( | |
349 base::TimeFormatShortDateAndTimeWithTimeZone(expires))); | |
350 } | 390 } |
351 cert_sub_fields->Append(std::move(sub_node_details)); | |
352 cert_sub_fields->Append(std::move(alt_node_details)); | |
353 | 391 |
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; | 392 x509_certificate_model::Extensions extensions; |
393 x509_certificate_model::GetExtensions( | 393 x509_certificate_model::GetExtensions( |
394 l10n_util::GetStringUTF8(IDS_CERT_EXTENSION_CRITICAL), | 394 l10n_util::GetStringUTF8(IDS_CERT_EXTENSION_CRITICAL), |
395 l10n_util::GetStringUTF8(IDS_CERT_EXTENSION_NON_CRITICAL), | 395 l10n_util::GetStringUTF8(IDS_CERT_EXTENSION_NON_CRITICAL), |
396 cert, &extensions); | 396 cert, &extensions); |
397 | 397 |
| 398 std::unique_ptr<base::DictionaryValue> details_extensions; |
398 if (!extensions.empty()) { | 399 if (!extensions.empty()) { |
399 cert_sub_fields = base::MakeUnique<base::ListValue>(); | 400 CertNodeBuilder details_extensions_builder(IDS_CERT_DETAILS_EXTENSIONS); |
400 | 401 for (const x509_certificate_model::Extension& extension : extensions) { |
401 for (x509_certificate_model::Extensions::const_iterator i = | 402 details_extensions_builder.Child( |
402 extensions.begin(); i != extensions.end(); ++i) { | 403 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 } | 404 } |
408 | 405 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 } | 406 } |
415 | 407 |
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; | 408 base::ListValue root_list; |
465 node_details = base::MakeUnique<base::DictionaryValue>(); | 409 root_list.Append( |
466 node_details->SetString("label", x509_certificate_model::GetTitle(cert)); | 410 CertNodeBuilder(x509_certificate_model::GetTitle(cert)) |
467 node_details->Set("children", std::move(cert_fields)); | 411 .Child( |
468 root_list.Append(std::move(node_details)); | 412 CertNodeBuilder( |
| 413 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_CERTIFICATE)) |
| 414 // Main certificate fields. |
| 415 .Child(version_node.Build()) |
| 416 .Child( |
| 417 CertNodeBuilder(IDS_CERT_DETAILS_SERIAL_NUMBER) |
| 418 .Payload( |
| 419 x509_certificate_model::GetSerialNumberHexified( |
| 420 cert, l10n_util::GetStringUTF8( |
| 421 IDS_CERT_INFO_FIELD_NOT_PRESENT))) |
| 422 .Build()) |
| 423 .Child(CertNodeBuilder(IDS_CERT_DETAILS_CERTIFICATE_SIG_ALG) |
| 424 .Payload(x509_certificate_model:: |
| 425 ProcessSecAlgorithmSignature(cert)) |
| 426 .Build()) |
| 427 .Child( |
| 428 CertNodeBuilder(IDS_CERT_DETAILS_ISSUER) |
| 429 .Payload(x509_certificate_model::GetIssuerName(cert)) |
| 430 .Build()) |
| 431 // Validity period. |
| 432 .Child(CertNodeBuilder(IDS_CERT_DETAILS_VALIDITY) |
| 433 .Child(issued_node_builder.Build()) |
| 434 .Child(expires_node_builder.Build()) |
| 435 .Build()) |
| 436 .Child( |
| 437 CertNodeBuilder(IDS_CERT_DETAILS_SUBJECT) |
| 438 .Payload(x509_certificate_model::GetSubjectName(cert)) |
| 439 .Build()) |
| 440 // Subject key information. |
| 441 .Child( |
| 442 CertNodeBuilder(IDS_CERT_DETAILS_SUBJECT_KEY_INFO) |
| 443 .Child( |
| 444 CertNodeBuilder(IDS_CERT_DETAILS_SUBJECT_KEY_ALG) |
| 445 .Payload( |
| 446 x509_certificate_model:: |
| 447 ProcessSecAlgorithmSubjectPublicKey( |
| 448 cert)) |
| 449 .Build()) |
| 450 .Child(CertNodeBuilder(IDS_CERT_DETAILS_SUBJECT_KEY) |
| 451 .Payload( |
| 452 x509_certificate_model:: |
| 453 ProcessSubjectPublicKeyInfo(cert)) |
| 454 .Build()) |
| 455 .Build()) |
| 456 // Extensions. |
| 457 .ChildIfNotNull(std::move(details_extensions)) |
| 458 .Child( |
| 459 CertNodeBuilder(IDS_CERT_DETAILS_CERTIFICATE_SIG_ALG) |
| 460 .Payload(x509_certificate_model:: |
| 461 ProcessSecAlgorithmSignatureWrap(cert)) |
| 462 .Build()) |
| 463 .Child(CertNodeBuilder(IDS_CERT_DETAILS_CERTIFICATE_SIG_VALUE) |
| 464 .Payload(x509_certificate_model:: |
| 465 ProcessRawBitsSignatureWrap(cert)) |
| 466 .Build()) |
| 467 .Child( |
| 468 CertNodeBuilder(IDS_CERT_INFO_FINGERPRINTS_GROUP) |
| 469 .Child(CertNodeBuilder( |
| 470 IDS_CERT_INFO_SHA256_FINGERPRINT_LABEL) |
| 471 .Payload( |
| 472 x509_certificate_model::HashCertSHA256( |
| 473 cert)) |
| 474 .Build()) |
| 475 .Child( |
| 476 CertNodeBuilder( |
| 477 IDS_CERT_INFO_SHA1_FINGERPRINT_LABEL) |
| 478 .Payload(x509_certificate_model::HashCertSHA1( |
| 479 cert)) |
| 480 .Build()) |
| 481 .Build()) |
| 482 .Build()) |
| 483 .Build()); |
469 | 484 |
470 // Send certificate information to javascript. | 485 // Send certificate information to javascript. |
471 web_ui()->CallJavascriptFunctionUnsafe("cert_viewer.getCertificateFields", | 486 web_ui()->CallJavascriptFunctionUnsafe("cert_viewer.getCertificateFields", |
472 root_list); | 487 root_list); |
473 } | 488 } |
474 | 489 |
475 int CertificateViewerDialogHandler::GetCertificateIndex( | 490 int CertificateViewerDialogHandler::GetCertificateIndex( |
476 const base::ListValue* args) const { | 491 const base::ListValue* args) const { |
477 int cert_index; | 492 int cert_index; |
478 double val; | 493 double val; |
479 if (!(args->GetDouble(0, &val))) | 494 if (!(args->GetDouble(0, &val))) |
480 return -1; | 495 return -1; |
481 cert_index = static_cast<int>(val); | 496 cert_index = static_cast<int>(val); |
482 if (cert_index < 0 || cert_index >= static_cast<int>(cert_chain_.size())) | 497 if (cert_index < 0 || cert_index >= static_cast<int>(cert_chain_.size())) |
483 return -1; | 498 return -1; |
484 return cert_index; | 499 return cert_index; |
485 } | 500 } |
OLD | NEW |