Index: extensions/browser/api/cast_channel/cast_socket.cc |
diff --git a/extensions/browser/api/cast_channel/cast_socket.cc b/extensions/browser/api/cast_channel/cast_socket.cc |
index 83994df6b1c413a28d43401689a4db0c8b973224..3f654e8c70da41b1d1e163d3efd2ef497ba8daba 100644 |
--- a/extensions/browser/api/cast_channel/cast_socket.cc |
+++ b/extensions/browser/api/cast_channel/cast_socket.cc |
@@ -163,6 +163,26 @@ bool CastSocket::ExtractPeerCert(std::string* cert) { |
logger_->LogSocketEvent(channel_id_, proto::SSL_INFO_OBTAINED); |
+ // 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
|
+ // excessive life-time (i.e. no more than 48 hrs). |
+ net::X509Certificate::OSCertHandles no_intermediates; |
+ scoped_refptr<net::X509Certificate> peer_cert = |
+ net::X509Certificate::CreateFromHandle(ssl_info.cert->os_cert_handle(), |
+ no_intermediates); |
+ |
+ base::Time expiry = peer_cert->valid_expiry(); |
+ if (expiry.is_null()) { |
+ return false; |
+ } |
+ |
+ base::Time should_have_expired_by = |
+ 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,
|
+ |
+ if (expiry > should_have_expired_by) { |
+ LOG(ERROR) << "Peer cert has excessive lifetime. notAfter=" << expiry; |
+ return false; |
+ } |
+ |
bool result = net::X509Certificate::GetDEREncoded( |
ssl_info.cert->os_cert_handle(), cert); |
if (result) { |