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

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

Issue 1011133005: Increase tolerance for receiver's certificate expiry (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
« 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 27 matching lines...) Expand all
38 #include "net/ssl/ssl_config_service.h" 38 #include "net/ssl/ssl_config_service.h"
39 #include "net/ssl/ssl_info.h" 39 #include "net/ssl/ssl_info.h"
40 40
41 // Assumes |ip_endpoint_| of type net::IPEndPoint and |channel_auth_| of enum 41 // Assumes |ip_endpoint_| of type net::IPEndPoint and |channel_auth_| of enum
42 // type ChannelAuthType are available in the current scope. 42 // type ChannelAuthType are available in the current scope.
43 #define VLOG_WITH_CONNECTION(level) VLOG(level) << "[" << \ 43 #define VLOG_WITH_CONNECTION(level) VLOG(level) << "[" << \
44 ip_endpoint_.ToString() << ", auth=" << channel_auth_ << "] " 44 ip_endpoint_.ToString() << ", auth=" << channel_auth_ << "] "
45 45
46 namespace { 46 namespace {
47 47
48 const int kMaxSelfSignedCertLifetimeInDays = 2; 48 const int kMaxSelfSignedCertLifetimeInDays = 4;
49 49
50 std::string FormatTimeForLogging(base::Time time) { 50 std::string FormatTimeForLogging(base::Time time) {
51 base::Time::Exploded exploded_time; 51 base::Time::Exploded exploded_time;
52 time.UTCExplode(&exploded_time); 52 time.UTCExplode(&exploded_time);
53 return base::StringPrintf( 53 return base::StringPrintf(
54 "%04d-%02d-%02d %02d:%02d:%02d.%03d UTC", exploded_time.year, 54 "%04d-%02d-%02d %02d:%02d:%02d.%03d UTC", exploded_time.year,
55 exploded_time.month, exploded_time.day_of_month, exploded_time.hour, 55 exploded_time.month, exploded_time.day_of_month, exploded_time.hour,
56 exploded_time.minute, exploded_time.second, exploded_time.millisecond); 56 exploded_time.minute, exploded_time.second, exploded_time.millisecond);
57 } 57 }
58 58
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 DCHECK(cert); 190 DCHECK(cert);
191 DCHECK(peer_cert_.empty()); 191 DCHECK(peer_cert_.empty());
192 net::SSLInfo ssl_info; 192 net::SSLInfo ssl_info;
193 if (!socket_->GetSSLInfo(&ssl_info) || !ssl_info.cert.get()) { 193 if (!socket_->GetSSLInfo(&ssl_info) || !ssl_info.cert.get()) {
194 return false; 194 return false;
195 } 195 }
196 196
197 logger_->LogSocketEvent(channel_id_, proto::SSL_INFO_OBTAINED); 197 logger_->LogSocketEvent(channel_id_, proto::SSL_INFO_OBTAINED);
198 198
199 // Ensure that the peer cert (which is self-signed) doesn't have an excessive 199 // Ensure that the peer cert (which is self-signed) doesn't have an excessive
200 // life-time (i.e. no more than 2 days). 200 // remaining life-time.
201 base::Time expiry = ssl_info.cert->valid_expiry(); 201 base::Time expiry = ssl_info.cert->valid_expiry();
202 base::Time lifetimeLimit = 202 base::Time lifetimeLimit =
203 base::Time::Now() + 203 base::Time::Now() +
204 base::TimeDelta::FromDays(kMaxSelfSignedCertLifetimeInDays); 204 base::TimeDelta::FromDays(kMaxSelfSignedCertLifetimeInDays);
205 if (expiry.is_null() || expiry > lifetimeLimit) { 205 if (expiry.is_null() || expiry > lifetimeLimit) {
206 std::string details = FormatTimeForLogging(expiry); 206 std::string details = FormatTimeForLogging(expiry);
207 details += " " + ip_endpoint().ToString(); 207 details += " " + ip_endpoint().ToString();
208 LOG(ERROR) << "Peer cert has excessive lifetime. details=" << details; 208 LOG(ERROR) << "Peer cert has excessive lifetime. details=" << details;
209 logger_->LogSocketEventWithDetails( 209 logger_->LogSocketEventWithDetails(
210 channel_id_, proto::SSL_CERT_EXCESSIVE_LIFETIME, details); 210 channel_id_, proto::SSL_CERT_EXCESSIVE_LIFETIME, details);
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 void CastSocketImpl::SetErrorState(ChannelError error_state) { 582 void CastSocketImpl::SetErrorState(ChannelError error_state) {
583 VLOG_WITH_CONNECTION(1) << "SetErrorState " << error_state; 583 VLOG_WITH_CONNECTION(1) << "SetErrorState " << error_state;
584 DCHECK_EQ(CHANNEL_ERROR_NONE, error_state_); 584 DCHECK_EQ(CHANNEL_ERROR_NONE, error_state_);
585 error_state_ = error_state; 585 error_state_ = error_state;
586 logger_->LogSocketErrorState(channel_id_, ErrorStateToProto(error_state_)); 586 logger_->LogSocketErrorState(channel_id_, ErrorStateToProto(error_state_));
587 } 587 }
588 } // namespace cast_channel 588 } // namespace cast_channel
589 } // namespace core_api 589 } // namespace core_api
590 } // namespace extensions 590 } // namespace extensions
591 #undef VLOG_WITH_CONNECTION 591 #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