Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Unified Diff: chrome/browser/devtools/devtools_ui_bindings.cc

Issue 2302873005: DevTools: allow devtools front-end to show certificate viewer. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/devtools/devtools_ui_bindings.cc
diff --git a/chrome/browser/devtools/devtools_ui_bindings.cc b/chrome/browser/devtools/devtools_ui_bindings.cc
index 77c639009ecbfdf5b85244e6b23474c6ae5801f3..fb7bd4808aa5c270d744831d9a13a9fcdc4b9059 100644
--- a/chrome/browser/devtools/devtools_ui_bindings.cc
+++ b/chrome/browser/devtools/devtools_ui_bindings.cc
@@ -41,12 +41,14 @@
#include "components/prefs/scoped_user_pref_update.h"
#include "components/syncable_prefs/pref_service_syncable.h"
#include "components/zoom/page_zoom.h"
+#include "content/public/browser/cert_store.h"
#include "content/public/browser/devtools_external_agent_proxy.h"
#include "content/public/browser/devtools_external_agent_proxy_delegate.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/render_frame_host.h"
+#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/user_metrics.h"
#include "content/public/browser/web_contents.h"
@@ -58,6 +60,7 @@
#include "ipc/ipc_channel.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
+#include "net/cert/x509_certificate.h"
#include "net/http/http_response_headers.h"
#include "net/url_request/url_fetcher.h"
#include "net/url_request/url_fetcher_response_writer.h"
@@ -675,6 +678,36 @@ void DevToolsUIBindings::SetWhitelistedShortcuts(const std::string& message) {
delegate_->SetWhitelistedShortcuts(message);
}
+void DevToolsUIBindings::ShowCertificateViewer(const std::string& cert_chain) {
+ std::unique_ptr<base::Value> value =
+ base::JSONReader::Read(cert_chain);
+ if (!value || value->GetType() != base::Value::TYPE_LIST)
+ return;
+
+ std::unique_ptr<base::ListValue> list =
+ base::ListValue::From(std::move(value));
+ std::vector<base::StringPiece> cert_string_piece;
+ for (size_t i = 0; i < list->GetSize(); ++i) {
+ std::string item;
+ if (list->GetString(i, &item))
+ cert_string_piece.push_back(item);
Ryan Sleevi 2016/09/02 18:20:30 SECURITY BUG: This is a use-after-free. You're cre
pfeldman 2016/09/02 18:54:43 Good catch. I did not even pay attention to the fa
+ }
+ scoped_refptr<net::X509Certificate> cert =
+ net::X509Certificate::CreateFromDERCertChain(cert_string_piece);
+ DCHECK(cert);
dgozman 2016/09/02 18:12:55 if (!cert) return;
Ryan Sleevi 2016/09/02 18:20:30 SECURITY BUG: Why this DCHECK()? You're taking unt
pfeldman 2016/09/02 18:54:43 Done.
+
+ // TODO(jam): temporarily add the certificate to the cert store to get an ID
+ // so that we don't have to change the WCD method signature
+ // (will be done in followups).
+ if (!agent_host_ || !agent_host_->GetWebContents())
+ return;
+ content::WebContents* inspected_wc = agent_host_->GetWebContents();
+ int cert_id = content::CertStore::GetInstance()->StoreCert(
pfeldman 2016/09/02 18:03:30 This is temporary, John removes it in a follow up.
+ cert.get(), inspected_wc->GetRenderProcessHost()->GetID());
Ryan Sleevi 2016/09/02 18:20:30 Is it guaranteed that inspected_wc will have an RP
pfeldman 2016/09/02 18:54:43 It is not. Done.
Ryan Sleevi 2016/09/02 19:27:40 Apologies for not being clearer. The TOCTOU issue
+ web_contents_->GetDelegate()->ShowCertificateViewerInDevTools(
+ web_contents_, cert_id);
+}
+
void DevToolsUIBindings::ZoomIn() {
zoom::PageZoom::Zoom(web_contents(), content::PAGE_ZOOM_IN);
}
« no previous file with comments | « chrome/browser/devtools/devtools_ui_bindings.h ('k') | third_party/WebKit/Source/devtools/front_end/devtools.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698