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

Side by Side Diff: extensions/browser/api/cast_channel/cast_socket.cc

Issue 694123002: Limit lifetime of self-signed certificate used for TLS on Cast channel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/browser/api/cast_channel/cast_socket.h" 5 #include "extensions/browser/api/cast_channel/cast_socket.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 bool CastSocket::ExtractPeerCert(std::string* cert) { 156 bool CastSocket::ExtractPeerCert(std::string* cert) {
157 DCHECK(cert); 157 DCHECK(cert);
158 DCHECK(peer_cert_.empty()); 158 DCHECK(peer_cert_.empty());
159 net::SSLInfo ssl_info; 159 net::SSLInfo ssl_info;
160 if (!socket_->GetSSLInfo(&ssl_info) || !ssl_info.cert.get()) { 160 if (!socket_->GetSSLInfo(&ssl_info) || !ssl_info.cert.get()) {
161 return false; 161 return false;
162 } 162 }
163 163
164 logger_->LogSocketEvent(channel_id_, proto::SSL_INFO_OBTAINED); 164 logger_->LogSocketEvent(channel_id_, proto::SSL_INFO_OBTAINED);
165 165
166 // we need to check that the peer cert (which is self-signed) doesn't have an
mark a. foltz 2014/11/01 20:17:34 Please write a function in either cast_auth_util.c
dougsteed 2014/11/03 21:06:11 I set out to do this as you suggested, but it seem
167 // excessive life-time (i.e. no more than 48 hrs).
168 net::X509Certificate::OSCertHandles no_intermediates;
169 scoped_refptr<net::X509Certificate> peer_cert =
170 net::X509Certificate::CreateFromHandle(ssl_info.cert->os_cert_handle(),
171 no_intermediates);
172
173 base::Time expiry = peer_cert->valid_expiry();
174 if (expiry.is_null()) {
175 return false;
176 }
177
178 base::Time should_have_expired_by =
179 base::Time::Now() + base::TimeDelta::FromDays(2);
mark a. foltz 2014/11/01 20:17:34 This is not really a security feature as the syste
dougsteed 2014/11/03 21:06:11 Yes, we know this is not a strong security check,
180
181 if (expiry > should_have_expired_by) {
182 LOG(ERROR) << "Peer cert has excessive lifetime. notAfter=" << expiry;
183 return false;
184 }
185
166 bool result = net::X509Certificate::GetDEREncoded( 186 bool result = net::X509Certificate::GetDEREncoded(
167 ssl_info.cert->os_cert_handle(), cert); 187 ssl_info.cert->os_cert_handle(), cert);
168 if (result) { 188 if (result) {
169 VLOG_WITH_CONNECTION(1) << "Successfully extracted peer certificate: " 189 VLOG_WITH_CONNECTION(1) << "Successfully extracted peer certificate: "
170 << *cert; 190 << *cert;
171 } 191 }
172 192
173 logger_->LogSocketEventWithRv( 193 logger_->LogSocketEventWithRv(
174 channel_id_, proto::DER_ENCODED_CERT_OBTAIN, result ? 1 : 0); 194 channel_id_, proto::DER_ENCODED_CERT_OBTAIN, result ? 1 : 0);
175 return result; 195 return result;
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 } 897 }
878 898
879 CastSocket::WriteRequest::~WriteRequest() { 899 CastSocket::WriteRequest::~WriteRequest() {
880 } 900 }
881 901
882 } // namespace cast_channel 902 } // namespace cast_channel
883 } // namespace core_api 903 } // namespace core_api
884 } // namespace extensions 904 } // namespace extensions
885 905
886 #undef VLOG_WITH_CONNECTION 906 #undef VLOG_WITH_CONNECTION
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698