| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/gtk/certificate_viewer.h" | 5 #include "chrome/browser/gtk/certificate_viewer.h" |
| 6 | 6 |
| 7 #include <cert.h> | |
| 8 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 9 #include <hasht.h> | |
| 10 #include <sechash.h> | |
| 11 | 8 |
| 12 #include <algorithm> | 9 #include <algorithm> |
| 13 #include <vector> | 10 #include <vector> |
| 14 | 11 |
| 15 #include "app/l10n_util.h" | 12 #include "app/l10n_util.h" |
| 16 #include "base/gtk_util.h" | 13 #include "base/gtk_util.h" |
| 17 #include "base/i18n/time_formatting.h" | 14 #include "base/i18n/time_formatting.h" |
| 18 #include "base/nss_util.h" | 15 #include "base/nss_util.h" |
| 19 #include "base/scoped_ptr.h" | 16 #include "base/scoped_ptr.h" |
| 20 #include "base/string_number_conversions.h" | 17 #include "base/string_number_conversions.h" |
| 21 #include "base/time.h" | 18 #include "base/time.h" |
| 22 #include "base/utf_string_conversions.h" | 19 #include "base/utf_string_conversions.h" |
| 23 #include "chrome/browser/gtk/certificate_dialogs.h" | 20 #include "chrome/browser/gtk/certificate_dialogs.h" |
| 24 #include "chrome/browser/gtk/gtk_util.h" | 21 #include "chrome/browser/gtk/gtk_util.h" |
| 25 #include "chrome/third_party/mozilla_security_manager/nsNSSCertHelper.h" | 22 #include "chrome/common/net/x509_certificate_model.h" |
| 26 #include "chrome/third_party/mozilla_security_manager/nsNSSCertificate.h" | |
| 27 #include "chrome/third_party/mozilla_security_manager/nsUsageArrayHelper.h" | |
| 28 #include "grit/generated_resources.h" | 23 #include "grit/generated_resources.h" |
| 29 #include "net/base/x509_certificate.h" | 24 #include "net/base/x509_certificate.h" |
| 30 | 25 |
| 31 // PSM = Mozilla's Personal Security Manager. | |
| 32 namespace psm = mozilla_security_manager; | |
| 33 | |
| 34 namespace { | 26 namespace { |
| 35 | 27 |
| 36 const char kDetailsFontFamily[] = "monospace"; | 28 const char kDetailsFontFamily[] = "monospace"; |
| 37 | 29 |
| 38 //////////////////////////////////////////////////////////////////////////////// | 30 //////////////////////////////////////////////////////////////////////////////// |
| 39 // NSS utility functions. | |
| 40 | |
| 41 // Convert a char* return value from NSS into a std::string and free the NSS | |
| 42 // memory. If the arg is NULL, a "Field Not Present" string will be returned | |
| 43 // instead. | |
| 44 std::string Stringize(char* nss_text) { | |
| 45 std::string s; | |
| 46 if (nss_text) { | |
| 47 s = nss_text; | |
| 48 PORT_Free(nss_text); | |
| 49 } else { | |
| 50 s = l10n_util::GetStringUTF8(IDS_CERT_INFO_FIELD_NOT_PRESENT); | |
| 51 } | |
| 52 return s; | |
| 53 } | |
| 54 | |
| 55 // Hash a certificate using the given algorithm, return the result as a | |
| 56 // colon-seperated hex string. The len specified is the number of bytes | |
| 57 // required for storing the raw fingerprint. | |
| 58 // (It's a bit redundant that the caller needs to specify len in addition to the | |
| 59 // algorithm, but given the limited uses, not worth fixing.) | |
| 60 std::string HashCert(CERTCertificate* cert, HASH_HashType algorithm, int len) { | |
| 61 unsigned char fingerprint[HASH_LENGTH_MAX]; | |
| 62 SECItem fingerprint_item; | |
| 63 | |
| 64 DCHECK(NULL != cert->derCert.data); | |
| 65 DCHECK(0 != cert->derCert.len); | |
| 66 DCHECK(len <= HASH_LENGTH_MAX); | |
| 67 memset(fingerprint, 0, len); | |
| 68 SECStatus rv = HASH_HashBuf(algorithm, fingerprint, cert->derCert.data, | |
| 69 cert->derCert.len); | |
| 70 DCHECK(rv == SECSuccess); | |
| 71 fingerprint_item.data = fingerprint; | |
| 72 fingerprint_item.len = len; | |
| 73 return psm::ProcessRawBytes(&fingerprint_item); | |
| 74 } | |
| 75 | |
| 76 std::string ProcessSecAlgorithm(SECAlgorithmID* algorithm_id) { | |
| 77 return psm::GetOIDText(&algorithm_id->algorithm); | |
| 78 } | |
| 79 | |
| 80 std::string ProcessExtension(CERTCertExtension* extension) { | |
| 81 std::string rv; | |
| 82 int criticality = IDS_CERT_EXTENSION_NON_CRITICAL; | |
| 83 if (extension->critical.data && extension->critical.data[0]) | |
| 84 criticality = IDS_CERT_EXTENSION_CRITICAL; | |
| 85 rv = l10n_util::GetStringUTF8(criticality) + "\n" + | |
| 86 psm::ProcessExtensionData(SECOID_FindOIDTag(&extension->id), | |
| 87 &extension->value); | |
| 88 return rv; | |
| 89 } | |
| 90 | |
| 91 //////////////////////////////////////////////////////////////////////////////// | |
| 92 // Gtk utility functions. | 31 // Gtk utility functions. |
| 93 | 32 |
| 94 void AddTitle(GtkTable* table, int row, const std::string& text) { | 33 void AddTitle(GtkTable* table, int row, const std::string& text) { |
| 95 gtk_table_attach_defaults(table, | 34 gtk_table_attach_defaults(table, |
| 96 gtk_util::CreateBoldLabel(text), | 35 gtk_util::CreateBoldLabel(text), |
| 97 0, 2, | 36 0, 2, |
| 98 row, row + 1); | 37 row, row + 1); |
| 99 } | 38 } |
| 100 | 39 |
| 101 void AddKeyValue(GtkTable* table, int row, const std::string& text, | 40 void AddKeyValue(GtkTable* table, int row, const std::string& text, |
| 102 const std::string& value) { | 41 const std::string& value) { |
| 103 gtk_table_attach_defaults( | 42 gtk_table_attach_defaults( |
| 104 table, | 43 table, |
| 105 gtk_util::IndentWidget( | 44 gtk_util::IndentWidget( |
| 106 gtk_util::LeftAlignMisc(gtk_label_new(text.c_str()))), | 45 gtk_util::LeftAlignMisc(gtk_label_new(text.c_str()))), |
| 107 0, 1, row, row + 1); | 46 0, 1, row, row + 1); |
| 108 gtk_table_attach_defaults( | 47 gtk_table_attach_defaults( |
| 109 table, | 48 table, |
| 110 gtk_util::LeftAlignMisc(gtk_label_new(value.c_str())), | 49 gtk_util::LeftAlignMisc(gtk_label_new(value.c_str())), |
| 111 1, 2, row, row + 1); | 50 1, 2, row, row + 1); |
| 112 } | 51 } |
| 113 | 52 |
| 114 //////////////////////////////////////////////////////////////////////////////// | 53 //////////////////////////////////////////////////////////////////////////////// |
| 115 // CertificateViewer class definition. | 54 // CertificateViewer class definition. |
| 116 | 55 |
| 117 class CertificateViewer { | 56 class CertificateViewer { |
| 118 public: | 57 public: |
| 119 CertificateViewer(gfx::NativeWindow parent, CERTCertList* cert_chain_list); | 58 CertificateViewer(gfx::NativeWindow parent, |
| 59 const net::X509Certificate::OSCertHandles& cert_chain_list); |
| 120 ~CertificateViewer(); | 60 ~CertificateViewer(); |
| 121 | 61 |
| 122 void InitGeneralPage(); | 62 void InitGeneralPage(); |
| 123 void InitDetailsPage(); | 63 void InitDetailsPage(); |
| 124 | 64 |
| 125 void Show(); | 65 void Show(); |
| 126 | 66 |
| 127 private: | 67 private: |
| 128 // Indices and column count for the certificate chain hierarchy tree store. | 68 // Indices and column count for the certificate chain hierarchy tree store. |
| 129 enum { | 69 enum { |
| 130 HIERARCHY_NAME, | 70 HIERARCHY_NAME, |
| 131 HIERARCHY_OBJECT, | 71 HIERARCHY_OBJECT, |
| 132 HIERARCHY_INDEX, | 72 HIERARCHY_INDEX, |
| 133 HIERARCHY_COLUMNS | 73 HIERARCHY_COLUMNS |
| 134 }; | 74 }; |
| 135 | 75 |
| 136 // Indices and column count for the certificate fields tree store. | 76 // Indices and column count for the certificate fields tree store. |
| 137 enum { | 77 enum { |
| 138 FIELDS_NAME, | 78 FIELDS_NAME, |
| 139 FIELDS_VALUE, | 79 FIELDS_VALUE, |
| 140 FIELDS_COLUMNS | 80 FIELDS_COLUMNS |
| 141 }; | 81 }; |
| 142 | 82 |
| 143 // Fill the tree store with the certificate hierarchy, and set |leaf| to the | 83 // Fill the tree store with the certificate hierarchy, and set |leaf| to the |
| 144 // iter of the leaf node. | 84 // iter of the leaf node. |
| 145 void FillHierarchyStore(GtkTreeStore* hierarchy_store, | 85 void FillHierarchyStore(GtkTreeStore* hierarchy_store, |
| 146 GtkTreeIter* leaf) const; | 86 GtkTreeIter* leaf) const; |
| 147 | 87 |
| 148 // Fill the tree store with the details of the given certificate. | 88 // Fill the tree store with the details of the given certificate. |
| 149 static void FillTreeStoreWithCertFields(GtkTreeStore* store, | 89 static void FillTreeStoreWithCertFields( |
| 150 CERTCertificate* cert); | 90 GtkTreeStore* store, net::X509Certificate::OSCertHandle cert); |
| 151 | 91 |
| 152 // Create a tree store filled with the details of the given certificate. | 92 // Create a tree store filled with the details of the given certificate. |
| 153 static GtkTreeStore* CreateFieldsTreeStore(CERTCertificate* cert); | 93 static GtkTreeStore* CreateFieldsTreeStore( |
| 94 net::X509Certificate::OSCertHandle cert); |
| 154 | 95 |
| 155 // Callbacks for user selecting elements in the trees. | 96 // Callbacks for user selecting elements in the trees. |
| 156 static void OnHierarchySelectionChanged(GtkTreeSelection* selection, | 97 static void OnHierarchySelectionChanged(GtkTreeSelection* selection, |
| 157 CertificateViewer* viewer); | 98 CertificateViewer* viewer); |
| 158 static void OnFieldsSelectionChanged(GtkTreeSelection* selection, | 99 static void OnFieldsSelectionChanged(GtkTreeSelection* selection, |
| 159 CertificateViewer* viewer); | 100 CertificateViewer* viewer); |
| 160 | 101 |
| 161 // Callback for export button. | 102 // Callback for export button. |
| 162 static void OnExportClicked(GtkButton *button, CertificateViewer* viewer); | 103 static void OnExportClicked(GtkButton *button, CertificateViewer* viewer); |
| 163 | 104 |
| 164 // The certificate hierarchy (leaf cert first). | 105 // The certificate hierarchy (leaf cert first). |
| 165 CERTCertList* cert_chain_list_; | 106 net::X509Certificate::OSCertHandles cert_chain_list_; |
| 166 // The same contents of cert_chain_list_ in a vector for easier access. | |
| 167 typedef std::vector<CERTCertificate*> CertificateVector; | |
| 168 CertificateVector cert_chain_; | |
| 169 | 107 |
| 170 GtkWidget* dialog_; | 108 GtkWidget* dialog_; |
| 171 GtkWidget* notebook_; | 109 GtkWidget* notebook_; |
| 172 GtkWidget* general_page_vbox_; | 110 GtkWidget* general_page_vbox_; |
| 173 GtkWidget* details_page_vbox_; | 111 GtkWidget* details_page_vbox_; |
| 174 GtkTreeSelection* hierarchy_selection_; | 112 GtkTreeSelection* hierarchy_selection_; |
| 175 GtkWidget* fields_tree_; | 113 GtkWidget* fields_tree_; |
| 176 GtkTextBuffer* field_value_buffer_; | 114 GtkTextBuffer* field_value_buffer_; |
| 177 GtkWidget* export_button_; | 115 GtkWidget* export_button_; |
| 178 | 116 |
| 179 DISALLOW_COPY_AND_ASSIGN(CertificateViewer); | 117 DISALLOW_COPY_AND_ASSIGN(CertificateViewer); |
| 180 }; | 118 }; |
| 181 | 119 |
| 182 //////////////////////////////////////////////////////////////////////////////// | 120 //////////////////////////////////////////////////////////////////////////////// |
| 183 // CertificateViewer implementation. | 121 // CertificateViewer implementation. |
| 184 | 122 |
| 185 // Close button callback. | 123 // Close button callback. |
| 186 void OnDialogResponse(GtkDialog* dialog, gint response_id, | 124 void OnDialogResponse(GtkDialog* dialog, gint response_id, |
| 187 gpointer user_data) { | 125 gpointer user_data) { |
| 188 // "Close" was clicked. | 126 // "Close" was clicked. |
| 189 gtk_widget_destroy(GTK_WIDGET(dialog)); | 127 gtk_widget_destroy(GTK_WIDGET(dialog)); |
| 190 } | 128 } |
| 191 | 129 |
| 192 void OnDestroy(GtkDialog* dialog, CertificateViewer* cert_viewer) { | 130 void OnDestroy(GtkDialog* dialog, CertificateViewer* cert_viewer) { |
| 193 delete cert_viewer; | 131 delete cert_viewer; |
| 194 } | 132 } |
| 195 | 133 |
| 196 CertificateViewer::CertificateViewer(gfx::NativeWindow parent, | 134 CertificateViewer::CertificateViewer( |
| 197 CERTCertList* cert_chain_list) | 135 gfx::NativeWindow parent, |
| 136 const net::X509Certificate::OSCertHandles& cert_chain_list) |
| 198 : cert_chain_list_(cert_chain_list) { | 137 : cert_chain_list_(cert_chain_list) { |
| 199 CERTCertListNode* node; | |
| 200 for (node = CERT_LIST_HEAD(cert_chain_list_); | |
| 201 !CERT_LIST_END(node, cert_chain_list_); | |
| 202 node = CERT_LIST_NEXT(node)) { | |
| 203 cert_chain_.push_back(node->cert); | |
| 204 } | |
| 205 | |
| 206 dialog_ = gtk_dialog_new_with_buttons( | 138 dialog_ = gtk_dialog_new_with_buttons( |
| 207 l10n_util::GetStringFUTF8( | 139 l10n_util::GetStringFUTF8( |
| 208 IDS_CERT_INFO_DIALOG_TITLE, | 140 IDS_CERT_INFO_DIALOG_TITLE, |
| 209 UTF8ToUTF16(psm::GetCertTitle(cert_chain_.front()))).c_str(), | 141 UTF8ToUTF16( |
| 142 x509_certificate_model::GetTitle( |
| 143 cert_chain_list_.front()))).c_str(), |
| 210 parent, | 144 parent, |
| 211 // Non-modal. | 145 // Non-modal. |
| 212 GTK_DIALOG_NO_SEPARATOR, | 146 GTK_DIALOG_NO_SEPARATOR, |
| 213 GTK_STOCK_CLOSE, | 147 GTK_STOCK_CLOSE, |
| 214 GTK_RESPONSE_CLOSE, | 148 GTK_RESPONSE_CLOSE, |
| 215 NULL); | 149 NULL); |
| 216 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog_)->vbox), | 150 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog_)->vbox), |
| 217 gtk_util::kContentAreaSpacing); | 151 gtk_util::kContentAreaSpacing); |
| 218 | 152 |
| 219 psm::RegisterDynamicOids(); | 153 x509_certificate_model::RegisterDynamicOids(); |
| 220 InitGeneralPage(); | 154 InitGeneralPage(); |
| 221 InitDetailsPage(); | 155 InitDetailsPage(); |
| 222 | 156 |
| 223 notebook_ = gtk_notebook_new(); | 157 notebook_ = gtk_notebook_new(); |
| 224 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog_)->vbox), notebook_); | 158 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog_)->vbox), notebook_); |
| 225 | 159 |
| 226 gtk_notebook_append_page( | 160 gtk_notebook_append_page( |
| 227 GTK_NOTEBOOK(notebook_), | 161 GTK_NOTEBOOK(notebook_), |
| 228 general_page_vbox_, | 162 general_page_vbox_, |
| 229 gtk_label_new_with_mnemonic( | 163 gtk_label_new_with_mnemonic( |
| 230 gtk_util::ConvertAcceleratorsFromWindowsStyle( | 164 gtk_util::ConvertAcceleratorsFromWindowsStyle( |
| 231 l10n_util::GetStringUTF8( | 165 l10n_util::GetStringUTF8( |
| 232 IDS_CERT_INFO_GENERAL_TAB_LABEL)).c_str())); | 166 IDS_CERT_INFO_GENERAL_TAB_LABEL)).c_str())); |
| 233 | 167 |
| 234 gtk_notebook_append_page( | 168 gtk_notebook_append_page( |
| 235 GTK_NOTEBOOK(notebook_), | 169 GTK_NOTEBOOK(notebook_), |
| 236 details_page_vbox_, | 170 details_page_vbox_, |
| 237 gtk_label_new_with_mnemonic( | 171 gtk_label_new_with_mnemonic( |
| 238 gtk_util::ConvertAcceleratorsFromWindowsStyle( | 172 gtk_util::ConvertAcceleratorsFromWindowsStyle( |
| 239 l10n_util::GetStringUTF8( | 173 l10n_util::GetStringUTF8( |
| 240 IDS_CERT_INFO_DETAILS_TAB_LABEL)).c_str())); | 174 IDS_CERT_INFO_DETAILS_TAB_LABEL)).c_str())); |
| 241 | 175 |
| 242 g_signal_connect(dialog_, "response", G_CALLBACK(OnDialogResponse), NULL); | 176 g_signal_connect(dialog_, "response", G_CALLBACK(OnDialogResponse), NULL); |
| 243 g_signal_connect(dialog_, "destroy", G_CALLBACK(OnDestroy), this); | 177 g_signal_connect(dialog_, "destroy", G_CALLBACK(OnDestroy), this); |
| 244 } | 178 } |
| 245 | 179 |
| 246 CertificateViewer::~CertificateViewer() { | 180 CertificateViewer::~CertificateViewer() { |
| 247 CERT_DestroyCertList(cert_chain_list_); | 181 x509_certificate_model::DestroyCertChain(&cert_chain_list_); |
| 248 } | 182 } |
| 249 | 183 |
| 250 void CertificateViewer::InitGeneralPage() { | 184 void CertificateViewer::InitGeneralPage() { |
| 251 CERTCertificate* cert = cert_chain_.front(); | 185 net::X509Certificate::OSCertHandle cert = cert_chain_list_.front(); |
| 252 general_page_vbox_ = gtk_vbox_new(FALSE, gtk_util::kContentAreaSpacing); | 186 general_page_vbox_ = gtk_vbox_new(FALSE, gtk_util::kContentAreaSpacing); |
| 253 gtk_container_set_border_width(GTK_CONTAINER(general_page_vbox_), | 187 gtk_container_set_border_width(GTK_CONTAINER(general_page_vbox_), |
| 254 gtk_util::kContentAreaBorder); | 188 gtk_util::kContentAreaBorder); |
| 255 | 189 |
| 256 GtkWidget* uses_vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); | 190 GtkWidget* uses_vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); |
| 257 gtk_box_pack_start(GTK_BOX(general_page_vbox_), uses_vbox, FALSE, FALSE, 0); | 191 gtk_box_pack_start(GTK_BOX(general_page_vbox_), uses_vbox, FALSE, FALSE, 0); |
| 258 gtk_box_pack_start( | 192 gtk_box_pack_start( |
| 259 GTK_BOX(uses_vbox), | 193 GTK_BOX(uses_vbox), |
| 260 gtk_util::CreateBoldLabel( | 194 gtk_util::CreateBoldLabel( |
| 261 l10n_util::GetStringUTF8(IDS_CERT_INFO_VERIFIED_USAGES_GROUP)), | 195 l10n_util::GetStringUTF8(IDS_CERT_INFO_VERIFIED_USAGES_GROUP)), |
| 262 FALSE, FALSE, 0); | 196 FALSE, FALSE, 0); |
| 263 | 197 |
| 264 std::vector<std::string> usages; | 198 std::vector<std::string> usages; |
| 265 psm::GetCertUsageStrings(cert, &usages); | 199 x509_certificate_model::GetUsageStrings(cert, &usages); |
| 266 for (size_t i = 0; i < usages.size(); ++i) | 200 for (size_t i = 0; i < usages.size(); ++i) |
| 267 gtk_box_pack_start( | 201 gtk_box_pack_start( |
| 268 GTK_BOX(uses_vbox), | 202 GTK_BOX(uses_vbox), |
| 269 gtk_util::IndentWidget(gtk_util::LeftAlignMisc(gtk_label_new( | 203 gtk_util::IndentWidget(gtk_util::LeftAlignMisc(gtk_label_new( |
| 270 usages[i].c_str()))), | 204 usages[i].c_str()))), |
| 271 FALSE, FALSE, 0); | 205 FALSE, FALSE, 0); |
| 272 | 206 |
| 273 gtk_box_pack_start(GTK_BOX(general_page_vbox_), gtk_hseparator_new(), | 207 gtk_box_pack_start(GTK_BOX(general_page_vbox_), gtk_hseparator_new(), |
| 274 FALSE, FALSE, 0); | 208 FALSE, FALSE, 0); |
| 275 | 209 |
| 276 const int num_rows = 21; | 210 const int num_rows = 21; |
| 277 GtkTable* table = GTK_TABLE(gtk_table_new(num_rows, 2, FALSE)); | 211 GtkTable* table = GTK_TABLE(gtk_table_new(num_rows, 2, FALSE)); |
| 278 gtk_table_set_col_spacing(table, 0, gtk_util::kLabelSpacing); | 212 gtk_table_set_col_spacing(table, 0, gtk_util::kLabelSpacing); |
| 279 gtk_table_set_row_spacings(table, gtk_util::kControlSpacing); | 213 gtk_table_set_row_spacings(table, gtk_util::kControlSpacing); |
| 280 | 214 |
| 281 gtk_box_pack_start(GTK_BOX(general_page_vbox_), GTK_WIDGET(table), | 215 gtk_box_pack_start(GTK_BOX(general_page_vbox_), GTK_WIDGET(table), |
| 282 FALSE, FALSE, 0); | 216 FALSE, FALSE, 0); |
| 283 int row = 0; | 217 int row = 0; |
| 218 const std::string alternative_text = |
| 219 l10n_util::GetStringUTF8(IDS_CERT_INFO_FIELD_NOT_PRESENT); |
| 284 AddTitle(table, row++, | 220 AddTitle(table, row++, |
| 285 l10n_util::GetStringUTF8(IDS_CERT_INFO_SUBJECT_GROUP)); | 221 l10n_util::GetStringUTF8(IDS_CERT_INFO_SUBJECT_GROUP)); |
| 286 AddKeyValue(table, row++, | 222 AddKeyValue(table, row++, |
| 287 l10n_util::GetStringUTF8(IDS_CERT_INFO_COMMON_NAME_LABEL), | 223 l10n_util::GetStringUTF8(IDS_CERT_INFO_COMMON_NAME_LABEL), |
| 288 psm::ProcessIDN(Stringize(CERT_GetCommonName(&cert->subject)))); | 224 x509_certificate_model::ProcessIDN( |
| 225 x509_certificate_model::GetSubjectCommonName( |
| 226 cert, alternative_text))); |
| 289 AddKeyValue(table, row++, | 227 AddKeyValue(table, row++, |
| 290 l10n_util::GetStringUTF8(IDS_CERT_INFO_ORGANIZATION_LABEL), | 228 l10n_util::GetStringUTF8(IDS_CERT_INFO_ORGANIZATION_LABEL), |
| 291 Stringize(CERT_GetOrgName(&cert->subject))); | 229 x509_certificate_model::GetSubjectOrgName( |
| 230 cert, alternative_text)); |
| 292 AddKeyValue(table, row++, | 231 AddKeyValue(table, row++, |
| 293 l10n_util::GetStringUTF8(IDS_CERT_INFO_ORGANIZATIONAL_UNIT_LABEL), | 232 l10n_util::GetStringUTF8(IDS_CERT_INFO_ORGANIZATIONAL_UNIT_LABEL), |
| 294 Stringize(CERT_GetOrgUnitName(&cert->subject))); | 233 x509_certificate_model::GetSubjectOrgUnitName( |
| 234 cert, alternative_text)); |
| 295 AddKeyValue(table, row++, | 235 AddKeyValue(table, row++, |
| 296 l10n_util::GetStringUTF8(IDS_CERT_INFO_SERIAL_NUMBER_LABEL), | 236 l10n_util::GetStringUTF8(IDS_CERT_INFO_SERIAL_NUMBER_LABEL), |
| 297 Stringize(CERT_Hexify(&cert->serialNumber, TRUE))); | 237 x509_certificate_model::GetSerialNumberHexified( |
| 238 cert, alternative_text)); |
| 298 | 239 |
| 299 row += 2; // Add spacing (kControlSpacing * 3 == kContentAreaSpacing). | 240 row += 2; // Add spacing (kControlSpacing * 3 == kContentAreaSpacing). |
| 300 | 241 |
| 301 AddTitle(table, row++, | 242 AddTitle(table, row++, |
| 302 l10n_util::GetStringUTF8(IDS_CERT_INFO_ISSUER_GROUP)); | 243 l10n_util::GetStringUTF8(IDS_CERT_INFO_ISSUER_GROUP)); |
| 303 AddKeyValue(table, row++, | 244 AddKeyValue(table, row++, |
| 304 l10n_util::GetStringUTF8(IDS_CERT_INFO_COMMON_NAME_LABEL), | 245 l10n_util::GetStringUTF8(IDS_CERT_INFO_COMMON_NAME_LABEL), |
| 305 psm::ProcessIDN(Stringize(CERT_GetCommonName(&cert->issuer)))); | 246 x509_certificate_model::ProcessIDN( |
| 247 x509_certificate_model::GetIssuerCommonName( |
| 248 cert, alternative_text))); |
| 306 AddKeyValue(table, row++, | 249 AddKeyValue(table, row++, |
| 307 l10n_util::GetStringUTF8(IDS_CERT_INFO_ORGANIZATION_LABEL), | 250 l10n_util::GetStringUTF8(IDS_CERT_INFO_ORGANIZATION_LABEL), |
| 308 Stringize(CERT_GetOrgName(&cert->issuer))); | 251 x509_certificate_model::GetIssuerOrgName( |
| 252 cert, alternative_text)); |
| 309 AddKeyValue(table, row++, | 253 AddKeyValue(table, row++, |
| 310 l10n_util::GetStringUTF8(IDS_CERT_INFO_ORGANIZATIONAL_UNIT_LABEL), | 254 l10n_util::GetStringUTF8(IDS_CERT_INFO_ORGANIZATIONAL_UNIT_LABEL), |
| 311 Stringize(CERT_GetOrgUnitName(&cert->issuer))); | 255 x509_certificate_model::GetIssuerOrgUnitName( |
| 256 cert, alternative_text)); |
| 312 | 257 |
| 313 row += 2; // Add spacing (kControlSpacing * 3 == kContentAreaSpacing). | 258 row += 2; // Add spacing (kControlSpacing * 3 == kContentAreaSpacing). |
| 314 | 259 |
| 315 PRTime issued, expires; | 260 base::Time issued, expires; |
| 316 std::string issued_str, expires_str; | 261 std::string issued_str, expires_str; |
| 317 if (CERT_GetCertTimes(cert, &issued, &expires) == SECSuccess) { | 262 if (x509_certificate_model::GetTimes(cert, &issued, &expires)) { |
| 318 issued_str = WideToUTF8( | 263 issued_str = WideToUTF8( |
| 319 base::TimeFormatShortDateNumeric(base::PRTimeToBaseTime(issued))); | 264 base::TimeFormatShortDateNumeric(issued)); |
| 320 expires_str = WideToUTF8( | 265 expires_str = WideToUTF8( |
| 321 base::TimeFormatShortDateNumeric(base::PRTimeToBaseTime(expires))); | 266 base::TimeFormatShortDateNumeric(expires)); |
| 322 } else { | 267 } else { |
| 323 issued_str = l10n_util::GetStringUTF8(IDS_CERT_INFO_FIELD_NOT_PRESENT); | 268 issued_str = alternative_text; |
| 324 expires_str = l10n_util::GetStringUTF8(IDS_CERT_INFO_FIELD_NOT_PRESENT); | 269 expires_str = alternative_text; |
| 325 } | 270 } |
| 326 AddTitle(table, row++, | 271 AddTitle(table, row++, |
| 327 l10n_util::GetStringUTF8(IDS_CERT_INFO_VALIDITY_GROUP)); | 272 l10n_util::GetStringUTF8(IDS_CERT_INFO_VALIDITY_GROUP)); |
| 328 AddKeyValue(table, row++, | 273 AddKeyValue(table, row++, |
| 329 l10n_util::GetStringUTF8(IDS_CERT_INFO_ISSUED_ON_LABEL), | 274 l10n_util::GetStringUTF8(IDS_CERT_INFO_ISSUED_ON_LABEL), |
| 330 issued_str); | 275 issued_str); |
| 331 AddKeyValue(table, row++, | 276 AddKeyValue(table, row++, |
| 332 l10n_util::GetStringUTF8(IDS_CERT_INFO_EXPIRES_ON_LABEL), | 277 l10n_util::GetStringUTF8(IDS_CERT_INFO_EXPIRES_ON_LABEL), |
| 333 expires_str); | 278 expires_str); |
| 334 | 279 |
| 335 row += 2; // Add spacing (kControlSpacing * 3 == kContentAreaSpacing). | 280 row += 2; // Add spacing (kControlSpacing * 3 == kContentAreaSpacing). |
| 336 | 281 |
| 337 AddTitle(table, row++, | 282 AddTitle(table, row++, |
| 338 l10n_util::GetStringUTF8(IDS_CERT_INFO_FINGERPRINTS_GROUP)); | 283 l10n_util::GetStringUTF8(IDS_CERT_INFO_FINGERPRINTS_GROUP)); |
| 339 AddKeyValue(table, row++, | 284 AddKeyValue(table, row++, |
| 340 l10n_util::GetStringUTF8(IDS_CERT_INFO_SHA256_FINGERPRINT_LABEL), | 285 l10n_util::GetStringUTF8(IDS_CERT_INFO_SHA256_FINGERPRINT_LABEL), |
| 341 HashCert(cert, HASH_AlgSHA256, SHA256_LENGTH)); | 286 x509_certificate_model::HashCertSHA256(cert)); |
| 342 AddKeyValue(table, row++, | 287 AddKeyValue(table, row++, |
| 343 l10n_util::GetStringUTF8(IDS_CERT_INFO_SHA1_FINGERPRINT_LABEL), | 288 l10n_util::GetStringUTF8(IDS_CERT_INFO_SHA1_FINGERPRINT_LABEL), |
| 344 HashCert(cert, HASH_AlgSHA1, SHA1_LENGTH)); | 289 x509_certificate_model::HashCertSHA1(cert)); |
| 345 | 290 |
| 346 DCHECK_EQ(row, num_rows); | 291 DCHECK_EQ(row, num_rows); |
| 347 } | 292 } |
| 348 | 293 |
| 349 void CertificateViewer::FillHierarchyStore(GtkTreeStore* hierarchy_store, | 294 void CertificateViewer::FillHierarchyStore(GtkTreeStore* hierarchy_store, |
| 350 GtkTreeIter* leaf) const { | 295 GtkTreeIter* leaf) const { |
| 351 GtkTreeIter parent; | 296 GtkTreeIter parent; |
| 352 GtkTreeIter* parent_ptr = NULL; | 297 GtkTreeIter* parent_ptr = NULL; |
| 353 GtkTreeIter iter; | 298 GtkTreeIter iter; |
| 354 gint index = cert_chain_.size() - 1; | 299 gint index = cert_chain_list_.size() - 1; |
| 355 for (CertificateVector::const_reverse_iterator i = cert_chain_.rbegin(); | 300 for (net::X509Certificate::OSCertHandles::const_reverse_iterator i = |
| 356 i != cert_chain_.rend(); ++i, --index) { | 301 cert_chain_list_.rbegin(); |
| 302 i != cert_chain_list_.rend(); ++i, --index) { |
| 357 gtk_tree_store_append(hierarchy_store, &iter, parent_ptr); | 303 gtk_tree_store_append(hierarchy_store, &iter, parent_ptr); |
| 358 GtkTreeStore* fields_store = CreateFieldsTreeStore(*i); | 304 GtkTreeStore* fields_store = CreateFieldsTreeStore(*i); |
| 359 gtk_tree_store_set( | 305 gtk_tree_store_set( |
| 360 hierarchy_store, &iter, | 306 hierarchy_store, &iter, |
| 361 HIERARCHY_NAME, psm::GetCertTitle(*i).c_str(), | 307 HIERARCHY_NAME, x509_certificate_model::GetTitle(*i).c_str(), |
| 362 HIERARCHY_OBJECT, fields_store, | 308 HIERARCHY_OBJECT, fields_store, |
| 363 HIERARCHY_INDEX, index, | 309 HIERARCHY_INDEX, index, |
| 364 -1); | 310 -1); |
| 365 g_object_unref(fields_store); | 311 g_object_unref(fields_store); |
| 366 parent = iter; | 312 parent = iter; |
| 367 parent_ptr = &parent; | 313 parent_ptr = &parent; |
| 368 } | 314 } |
| 369 *leaf = iter; | 315 *leaf = iter; |
| 370 } | 316 } |
| 371 | 317 |
| 372 // static | 318 // static |
| 373 void CertificateViewer::FillTreeStoreWithCertFields(GtkTreeStore* store, | 319 void CertificateViewer::FillTreeStoreWithCertFields( |
| 374 CERTCertificate* cert) { | 320 GtkTreeStore* store, net::X509Certificate::OSCertHandle cert) { |
| 375 GtkTreeIter top; | 321 GtkTreeIter top; |
| 376 gtk_tree_store_append(store, &top, NULL); | 322 gtk_tree_store_append(store, &top, NULL); |
| 377 gtk_tree_store_set( | 323 gtk_tree_store_set( |
| 378 store, &top, | 324 store, &top, |
| 379 FIELDS_NAME, psm::GetCertTitle(cert).c_str(), | 325 FIELDS_NAME, x509_certificate_model::GetTitle(cert).c_str(), |
| 380 FIELDS_VALUE, "", | 326 FIELDS_VALUE, "", |
| 381 -1); | 327 -1); |
| 382 | 328 |
| 383 GtkTreeIter cert_iter; | 329 GtkTreeIter cert_iter; |
| 384 gtk_tree_store_append(store, &cert_iter, &top); | 330 gtk_tree_store_append(store, &cert_iter, &top); |
| 385 gtk_tree_store_set( | 331 gtk_tree_store_set( |
| 386 store, &cert_iter, | 332 store, &cert_iter, |
| 387 FIELDS_NAME, | 333 FIELDS_NAME, |
| 388 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_CERTIFICATE).c_str(), | 334 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_CERTIFICATE).c_str(), |
| 389 FIELDS_VALUE, "", | 335 FIELDS_VALUE, "", |
| 390 -1); | 336 -1); |
| 391 | 337 |
| 392 unsigned long version = ULONG_MAX; | |
| 393 std::string version_str; | 338 std::string version_str; |
| 394 if (SEC_ASN1DecodeInteger(&cert->version, &version) == SECSuccess && | 339 std::string version = x509_certificate_model::GetVersion(cert); |
| 395 version != ULONG_MAX) | 340 if (!version.empty()) |
| 396 version_str = l10n_util::GetStringFUTF8(IDS_CERT_DETAILS_VERSION_FORMAT, | 341 version_str = l10n_util::GetStringFUTF8(IDS_CERT_DETAILS_VERSION_FORMAT, |
| 397 base::UintToString16(version + 1)); | 342 UTF8ToUTF16(version)); |
| 398 GtkTreeIter iter; | 343 GtkTreeIter iter; |
| 399 gtk_tree_store_append(store, &iter, &cert_iter); | 344 gtk_tree_store_append(store, &iter, &cert_iter); |
| 400 gtk_tree_store_set( | 345 gtk_tree_store_set( |
| 401 store, &iter, | 346 store, &iter, |
| 402 FIELDS_NAME, | 347 FIELDS_NAME, |
| 403 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_VERSION).c_str(), | 348 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_VERSION).c_str(), |
| 404 FIELDS_VALUE, version_str.c_str(), | 349 FIELDS_VALUE, version_str.c_str(), |
| 405 -1); | 350 -1); |
| 406 | 351 |
| 407 gtk_tree_store_append(store, &iter, &cert_iter); | 352 gtk_tree_store_append(store, &iter, &cert_iter); |
| 408 gtk_tree_store_set( | 353 gtk_tree_store_set( |
| 409 store, &iter, | 354 store, &iter, |
| 410 FIELDS_NAME, | 355 FIELDS_NAME, |
| 411 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_SERIAL_NUMBER).c_str(), | 356 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_SERIAL_NUMBER).c_str(), |
| 412 FIELDS_VALUE, Stringize(CERT_Hexify(&cert->serialNumber, TRUE)).c_str(), | 357 FIELDS_VALUE, |
| 358 x509_certificate_model::GetSerialNumberHexified( |
| 359 cert, |
| 360 l10n_util::GetStringUTF8(IDS_CERT_INFO_FIELD_NOT_PRESENT)).c_str(), |
| 413 -1); | 361 -1); |
| 414 | 362 |
| 415 gtk_tree_store_append(store, &iter, &cert_iter); | 363 gtk_tree_store_append(store, &iter, &cert_iter); |
| 416 gtk_tree_store_set( | 364 gtk_tree_store_set( |
| 417 store, &iter, | 365 store, &iter, |
| 418 FIELDS_NAME, | 366 FIELDS_NAME, |
| 419 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_CERTIFICATE_SIG_ALG).c_str(), | 367 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_CERTIFICATE_SIG_ALG).c_str(), |
| 420 FIELDS_VALUE, ProcessSecAlgorithm(&cert->signature).c_str(), | 368 FIELDS_VALUE, |
| 369 x509_certificate_model::ProcessSecAlgorithmSignature(cert).c_str(), |
| 421 -1); | 370 -1); |
| 422 | 371 |
| 423 gtk_tree_store_append(store, &iter, &cert_iter); | 372 gtk_tree_store_append(store, &iter, &cert_iter); |
| 424 gtk_tree_store_set( | 373 gtk_tree_store_set( |
| 425 store, &iter, | 374 store, &iter, |
| 426 FIELDS_NAME, | 375 FIELDS_NAME, |
| 427 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_ISSUER).c_str(), | 376 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_ISSUER).c_str(), |
| 428 FIELDS_VALUE, psm::ProcessName(&cert->issuer).c_str(), | 377 FIELDS_VALUE, x509_certificate_model::GetIssuerName(cert).c_str(), |
| 429 -1); | 378 -1); |
| 430 | 379 |
| 431 GtkTreeIter validity_iter; | 380 GtkTreeIter validity_iter; |
| 432 gtk_tree_store_append(store, &validity_iter, &cert_iter); | 381 gtk_tree_store_append(store, &validity_iter, &cert_iter); |
| 433 gtk_tree_store_set( | 382 gtk_tree_store_set( |
| 434 store, &validity_iter, | 383 store, &validity_iter, |
| 435 FIELDS_NAME, | 384 FIELDS_NAME, |
| 436 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_VALIDITY).c_str(), | 385 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_VALIDITY).c_str(), |
| 437 FIELDS_VALUE, "", | 386 FIELDS_VALUE, "", |
| 438 -1); | 387 -1); |
| 439 | 388 |
| 440 PRTime issued, expires; | 389 base::Time issued, expires; |
| 441 std::string issued_str, expires_str; | 390 std::string issued_str, expires_str; |
| 442 if (CERT_GetCertTimes(cert, &issued, &expires) == SECSuccess) { | 391 if (x509_certificate_model::GetTimes(cert, &issued, &expires)) { |
| 443 issued_str = WideToUTF8( | 392 issued_str = WideToUTF8(base::TimeFormatShortDateAndTime(issued)); |
| 444 base::TimeFormatShortDateAndTime(base::PRTimeToBaseTime(issued))); | 393 expires_str = WideToUTF8(base::TimeFormatShortDateAndTime(expires)); |
| 445 expires_str = WideToUTF8( | |
| 446 base::TimeFormatShortDateAndTime(base::PRTimeToBaseTime(expires))); | |
| 447 } | 394 } |
| 448 gtk_tree_store_append(store, &iter, &validity_iter); | 395 gtk_tree_store_append(store, &iter, &validity_iter); |
| 449 gtk_tree_store_set( | 396 gtk_tree_store_set( |
| 450 store, &iter, | 397 store, &iter, |
| 451 FIELDS_NAME, | 398 FIELDS_NAME, |
| 452 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_NOT_BEFORE).c_str(), | 399 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_NOT_BEFORE).c_str(), |
| 453 FIELDS_VALUE, issued_str.c_str(), | 400 FIELDS_VALUE, issued_str.c_str(), |
| 454 -1); | 401 -1); |
| 455 gtk_tree_store_append(store, &iter, &validity_iter); | 402 gtk_tree_store_append(store, &iter, &validity_iter); |
| 456 gtk_tree_store_set( | 403 gtk_tree_store_set( |
| 457 store, &iter, | 404 store, &iter, |
| 458 FIELDS_NAME, | 405 FIELDS_NAME, |
| 459 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_NOT_AFTER).c_str(), | 406 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_NOT_AFTER).c_str(), |
| 460 FIELDS_VALUE, expires_str.c_str(), | 407 FIELDS_VALUE, expires_str.c_str(), |
| 461 -1); | 408 -1); |
| 462 | 409 |
| 463 gtk_tree_store_append(store, &iter, &cert_iter); | 410 gtk_tree_store_append(store, &iter, &cert_iter); |
| 464 gtk_tree_store_set( | 411 gtk_tree_store_set( |
| 465 store, &iter, | 412 store, &iter, |
| 466 FIELDS_NAME, | 413 FIELDS_NAME, |
| 467 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_SUBJECT).c_str(), | 414 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_SUBJECT).c_str(), |
| 468 FIELDS_VALUE, psm::ProcessName(&cert->subject).c_str(), | 415 FIELDS_VALUE, x509_certificate_model::GetSubjectName(cert).c_str(), |
| 469 -1); | 416 -1); |
| 470 | 417 |
| 471 GtkTreeIter subject_public_key_iter; | 418 GtkTreeIter subject_public_key_iter; |
| 472 gtk_tree_store_append(store, &subject_public_key_iter, &cert_iter); | 419 gtk_tree_store_append(store, &subject_public_key_iter, &cert_iter); |
| 473 gtk_tree_store_set( | 420 gtk_tree_store_set( |
| 474 store, &subject_public_key_iter, | 421 store, &subject_public_key_iter, |
| 475 FIELDS_NAME, | 422 FIELDS_NAME, |
| 476 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_SUBJECT_KEY_INFO).c_str(), | 423 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_SUBJECT_KEY_INFO).c_str(), |
| 477 FIELDS_VALUE, "", | 424 FIELDS_VALUE, "", |
| 478 -1); | 425 -1); |
| 479 | 426 |
| 480 gtk_tree_store_append(store, &iter, &subject_public_key_iter); | 427 gtk_tree_store_append(store, &iter, &subject_public_key_iter); |
| 481 gtk_tree_store_set( | 428 gtk_tree_store_set( |
| 482 store, &iter, | 429 store, &iter, |
| 483 FIELDS_NAME, | 430 FIELDS_NAME, |
| 484 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_SUBJECT_KEY_ALG).c_str(), | 431 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_SUBJECT_KEY_ALG).c_str(), |
| 485 FIELDS_VALUE, | 432 FIELDS_VALUE, |
| 486 ProcessSecAlgorithm(&cert->subjectPublicKeyInfo.algorithm).c_str(), | 433 x509_certificate_model::ProcessSecAlgorithmSubjectPublicKey(cert).c_str(), |
| 487 -1); | 434 -1); |
| 488 | 435 |
| 489 gtk_tree_store_append(store, &iter, &subject_public_key_iter); | 436 gtk_tree_store_append(store, &iter, &subject_public_key_iter); |
| 490 gtk_tree_store_set( | 437 gtk_tree_store_set( |
| 491 store, &iter, | 438 store, &iter, |
| 492 FIELDS_NAME, | 439 FIELDS_NAME, |
| 493 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_SUBJECT_KEY).c_str(), | 440 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_SUBJECT_KEY).c_str(), |
| 494 FIELDS_VALUE, | 441 FIELDS_VALUE, |
| 495 psm::ProcessSubjectPublicKeyInfo(&cert->subjectPublicKeyInfo).c_str(), | 442 x509_certificate_model::ProcessSubjectPublicKeyInfo(cert).c_str(), |
| 496 -1); | 443 -1); |
| 497 | 444 |
| 498 if (cert->extensions) { | 445 x509_certificate_model::Extensions extensions; |
| 446 x509_certificate_model::GetExtensions( |
| 447 l10n_util::GetStringUTF8(IDS_CERT_EXTENSION_CRITICAL), |
| 448 l10n_util::GetStringUTF8(IDS_CERT_EXTENSION_NON_CRITICAL), |
| 449 cert, &extensions); |
| 450 |
| 451 if (!extensions.empty()) { |
| 499 GtkTreeIter extensions_iter; | 452 GtkTreeIter extensions_iter; |
| 500 gtk_tree_store_append(store, &extensions_iter, &cert_iter); | 453 gtk_tree_store_append(store, &extensions_iter, &cert_iter); |
| 501 gtk_tree_store_set( | 454 gtk_tree_store_set( |
| 502 store, &extensions_iter, | 455 store, &extensions_iter, |
| 503 FIELDS_NAME, | 456 FIELDS_NAME, |
| 504 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_EXTENSIONS).c_str(), | 457 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_EXTENSIONS).c_str(), |
| 505 FIELDS_VALUE, "", | 458 FIELDS_VALUE, "", |
| 506 -1); | 459 -1); |
| 507 | 460 |
| 508 for (size_t i = 0; cert->extensions[i] != NULL; ++i) { | 461 for (x509_certificate_model::Extensions::const_iterator i = |
| 462 extensions.begin(); i != extensions.end(); ++i) { |
| 509 gtk_tree_store_append(store, &iter, &extensions_iter); | 463 gtk_tree_store_append(store, &iter, &extensions_iter); |
| 510 gtk_tree_store_set( | 464 gtk_tree_store_set( |
| 511 store, &iter, | 465 store, &iter, |
| 512 FIELDS_NAME, psm::GetOIDText(&cert->extensions[i]->id).c_str(), | 466 FIELDS_NAME, i->name.c_str(), |
| 513 FIELDS_VALUE, ProcessExtension(cert->extensions[i]).c_str(), | 467 FIELDS_VALUE, i->value.c_str(), |
| 514 -1); | 468 -1); |
| 515 } | 469 } |
| 516 } | 470 } |
| 517 | 471 |
| 518 gtk_tree_store_append(store, &iter, &top); | 472 gtk_tree_store_append(store, &iter, &top); |
| 519 gtk_tree_store_set( | 473 gtk_tree_store_set( |
| 520 store, &iter, | 474 store, &iter, |
| 521 FIELDS_NAME, | 475 FIELDS_NAME, |
| 522 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_CERTIFICATE_SIG_ALG).c_str(), | 476 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_CERTIFICATE_SIG_ALG).c_str(), |
| 523 FIELDS_VALUE, | 477 FIELDS_VALUE, |
| 524 ProcessSecAlgorithm(&cert->signatureWrap.signatureAlgorithm).c_str(), | 478 x509_certificate_model::ProcessSecAlgorithmSignatureWrap(cert).c_str(), |
| 525 -1); | 479 -1); |
| 526 | 480 |
| 527 gtk_tree_store_append(store, &iter, &top); | 481 gtk_tree_store_append(store, &iter, &top); |
| 528 gtk_tree_store_set( | 482 gtk_tree_store_set( |
| 529 store, &iter, | 483 store, &iter, |
| 530 FIELDS_NAME, | 484 FIELDS_NAME, |
| 531 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_CERTIFICATE_SIG_VALUE).c_str(), | 485 l10n_util::GetStringUTF8(IDS_CERT_DETAILS_CERTIFICATE_SIG_VALUE).c_str(), |
| 532 FIELDS_VALUE, psm::ProcessRawBits(&cert->signatureWrap.signature).c_str(), | 486 FIELDS_VALUE, |
| 487 x509_certificate_model::ProcessRawBitsSignatureWrap(cert).c_str(), |
| 533 -1); | 488 -1); |
| 534 } | 489 } |
| 535 | 490 |
| 536 // static | 491 // static |
| 537 GtkTreeStore* CertificateViewer::CreateFieldsTreeStore(CERTCertificate* cert) { | 492 GtkTreeStore* CertificateViewer::CreateFieldsTreeStore( |
| 493 net::X509Certificate::OSCertHandle cert) { |
| 538 GtkTreeStore* fields_store = gtk_tree_store_new(FIELDS_COLUMNS, G_TYPE_STRING, | 494 GtkTreeStore* fields_store = gtk_tree_store_new(FIELDS_COLUMNS, G_TYPE_STRING, |
| 539 G_TYPE_STRING); | 495 G_TYPE_STRING); |
| 540 FillTreeStoreWithCertFields(fields_store, cert); | 496 FillTreeStoreWithCertFields(fields_store, cert); |
| 541 return fields_store; | 497 return fields_store; |
| 542 } | 498 } |
| 543 | 499 |
| 544 void CertificateViewer::InitDetailsPage() { | 500 void CertificateViewer::InitDetailsPage() { |
| 545 details_page_vbox_ = gtk_vbox_new(FALSE, gtk_util::kContentAreaSpacing); | 501 details_page_vbox_ = gtk_vbox_new(FALSE, gtk_util::kContentAreaSpacing); |
| 546 gtk_container_set_border_width(GTK_CONTAINER(details_page_vbox_), | 502 gtk_container_set_border_width(GTK_CONTAINER(details_page_vbox_), |
| 547 gtk_util::kContentAreaBorder); | 503 gtk_util::kContentAreaBorder); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 return; | 665 return; |
| 710 gint cert_index = -1; | 666 gint cert_index = -1; |
| 711 gtk_tree_model_get(model, &iter, HIERARCHY_INDEX, &cert_index, -1); | 667 gtk_tree_model_get(model, &iter, HIERARCHY_INDEX, &cert_index, -1); |
| 712 | 668 |
| 713 if (cert_index < 0) { | 669 if (cert_index < 0) { |
| 714 NOTREACHED(); | 670 NOTREACHED(); |
| 715 return; | 671 return; |
| 716 } | 672 } |
| 717 | 673 |
| 718 ShowCertExportDialog(GTK_WINDOW(viewer->dialog_), | 674 ShowCertExportDialog(GTK_WINDOW(viewer->dialog_), |
| 719 viewer->cert_chain_[cert_index]); | 675 viewer->cert_chain_list_[cert_index]); |
| 720 } | 676 } |
| 721 | 677 |
| 722 void CertificateViewer::Show() { | 678 void CertificateViewer::Show() { |
| 723 gtk_util::ShowDialog(dialog_); | 679 gtk_util::ShowDialog(dialog_); |
| 724 } | 680 } |
| 725 | 681 |
| 726 } // namespace | 682 } // namespace |
| 727 | 683 |
| 728 void ShowCertificateViewer(gfx::NativeWindow parent, CERTCertificate* cert) { | 684 void ShowCertificateViewer(gfx::NativeWindow parent, |
| 729 CERTCertList* cert_chain = CERT_GetCertChainFromCert( | 685 net::X509Certificate::OSCertHandle cert) { |
| 730 cert, PR_Now(), certUsageSSLServer); | 686 net::X509Certificate::OSCertHandles cert_chain; |
| 731 DCHECK(cert_chain); | 687 x509_certificate_model::GetCertChainFromCert(cert, &cert_chain); |
| 732 (new CertificateViewer(parent, cert_chain))->Show(); | 688 (new CertificateViewer(parent, cert_chain))->Show(); |
| 733 } | 689 } |
| 734 | 690 |
| 735 void ShowCertificateViewer(gfx::NativeWindow parent, | 691 void ShowCertificateViewer(gfx::NativeWindow parent, |
| 736 net::X509Certificate* cert) { | 692 net::X509Certificate* cert) { |
| 737 ShowCertificateViewer(parent, cert->os_cert_handle()); | 693 ShowCertificateViewer(parent, cert->os_cert_handle()); |
| 738 } | 694 } |
| OLD | NEW |