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

Side by Side Diff: content/browser/renderer_host/x509_user_cert_resource_handler.cc

Issue 10377025: Parse an application/x-x509-user-cert response with (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | net/base/cert_database_nss.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/browser/renderer_host/x509_user_cert_resource_handler.h" 5 #include "content/browser/renderer_host/x509_user_cert_resource_handler.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "content/browser/renderer_host/resource_request_info_impl.h" 8 #include "content/browser/renderer_host/resource_request_info_impl.h"
9 #include "content/public/browser/content_browser_client.h" 9 #include "content/public/browser/content_browser_client.h"
10 #include "content/public/common/resource_response.h" 10 #include "content/public/common/resource_response.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 bool X509UserCertResourceHandler::OnResponseCompleted( 94 bool X509UserCertResourceHandler::OnResponseCompleted(
95 int request_id, 95 int request_id,
96 const net::URLRequestStatus& urs, 96 const net::URLRequestStatus& urs,
97 const std::string& sec_info) { 97 const std::string& sec_info) {
98 if (urs.status() != net::URLRequestStatus::SUCCESS) 98 if (urs.status() != net::URLRequestStatus::SUCCESS)
99 return false; 99 return false;
100 100
101 AssembleResource(); 101 AssembleResource();
102 scoped_refptr<net::X509Certificate> cert; 102 scoped_refptr<net::X509Certificate> cert;
103 if (resource_buffer_) { 103 if (resource_buffer_) {
104 cert = net::X509Certificate::CreateFromBytes(resource_buffer_->data(), 104 FILE* file = fopen("keygen-response", "w");
105 content_length_); 105 fwrite(resource_buffer_->data(), 1, content_length_, file);
106 fclose(file);
107 net::CertificateList cert_list =
108 net::X509Certificate::CreateCertificateListFromBytes(
109 resource_buffer_->data(), content_length_,
110 net::X509Certificate::FORMAT_AUTO);
111 if (cert_list.size()) {
112 fprintf(stderr, "cert_list.size()=%d\n", (int)cert_list.size());
113 net::X509Certificate::OSCertHandle cert_handle =
114 cert_list[0]->os_cert_handle();
115 net::X509Certificate::OSCertHandles intermediate_certs;
116 for (size_t i = 1; i < cert_list.size(); ++i)
117 intermediate_certs.push_back(cert_list[i]->os_cert_handle());
118 cert = net::X509Certificate::CreateFromHandle(cert_handle,
119 intermediate_certs);
120 }
106 } 121 }
122 // TODO(wtc): change ContentBrowserClient::AddNewCertificate() to take
123 // a net::CertificateList instead of a net::X509Certificate?
107 content::GetContentClient()->browser()->AddNewCertificate( 124 content::GetContentClient()->browser()->AddNewCertificate(
108 request_, cert, render_process_host_id_, render_view_id_); 125 request_, cert, render_process_host_id_, render_view_id_);
109 return true; 126 return true;
110 } 127 }
111 128
112 void X509UserCertResourceHandler::OnRequestClosed() { 129 void X509UserCertResourceHandler::OnRequestClosed() {
113 } 130 }
114 131
115 X509UserCertResourceHandler::~X509UserCertResourceHandler() { 132 X509UserCertResourceHandler::~X509UserCertResourceHandler() {
116 } 133 }
117 134
118 void X509UserCertResourceHandler::AssembleResource() { 135 void X509UserCertResourceHandler::AssembleResource() {
119 size_t assembled_bytes = 0; 136 size_t assembled_bytes = 0;
120 resource_buffer_ = content::AssembleData(buffer_, &assembled_bytes); 137 resource_buffer_ = content::AssembleData(buffer_, &assembled_bytes);
121 DCHECK_EQ(content_length_, assembled_bytes); 138 DCHECK_EQ(content_length_, assembled_bytes);
122 } 139 }
OLDNEW
« no previous file with comments | « no previous file | net/base/cert_database_nss.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698