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

Unified Diff: webrtc/base/opensslstreamadapter.h

Issue 2163683003: Relanding: Allow the DTLS fingerprint verification to occur after the handshake. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Code cleanup based on comments from Matt. Setting DTLS state to "failed" on bad fingerprint. Created 4 years, 5 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
« no previous file with comments | « no previous file | webrtc/base/opensslstreamadapter.cc » ('j') | webrtc/base/opensslstreamadapter.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/opensslstreamadapter.h
diff --git a/webrtc/base/opensslstreamadapter.h b/webrtc/base/opensslstreamadapter.h
index 05e81021696162b626029bf2a9d723475305665c..d124798e370d7323d54fc842b733e4c4f1b29cc0 100644
--- a/webrtc/base/opensslstreamadapter.h
+++ b/webrtc/base/opensslstreamadapter.h
@@ -107,6 +107,8 @@ class OpenSSLStreamAdapter : public SSLStreamAdapter {
bool SetDtlsSrtpCryptoSuites(const std::vector<int>& crypto_suites) override;
bool GetDtlsSrtpCryptoSuite(int* crypto_suite) override;
+ bool IsTlsConnected() override { return state_ == SSL_CONNECTED; }
+
// Capabilities interfaces
static bool HaveDtls();
static bool HaveDtlsSrtp();
@@ -133,6 +135,12 @@ class OpenSSLStreamAdapter : public SSLStreamAdapter {
enum { MSG_TIMEOUT = MSG_MAX+1};
+ enum SSLTopology {
mattdr-at-webrtc.org 2016/07/21 08:04:23 SSL really only has one topology: client-server. T
Taylor Brandstetter 2016/07/22 18:52:20 Enum dropped, as discussed.
pthatcher1 2016/07/22 18:58:27 Nothing every uses StartSSLWithServer any more, so
Taylor Brandstetter 2016/07/25 23:54:53 Can we remove StartSSLWithServer in a separate CL,
+ TOPOLOGY_CLIENT_SERVER,
+ TOPOLOGY_PEER_TO_PEER,
+ TOPOLOGY_UNKNOWN
+ };
+
// The following three methods return 0 on success and a negative
// error code on failure. The error code may be from OpenSSL or -1
// on some other error cases, so it can't really be interpreted
@@ -165,15 +173,26 @@ class OpenSSLStreamAdapter : public SSLStreamAdapter {
// SSL library configuration
SSL_CTX* SetupSSLContext();
// SSL verification check
- bool SSLPostConnectionCheck(SSL* ssl, const char* server_name,
- const X509* peer_cert,
- const std::string& peer_digest);
+ bool SSLPostConnectionCheck();
+ bool VerifyPeerCertificate();
// SSL certification verification error handler, called back from
// the openssl library. Returns an int interpreted as a boolean in
// the C style: zero means verification failure, non-zero means
// passed.
static int SSLVerifyCallback(int ok, X509_STORE_CTX* store);
+ bool waiting_to_verify_client_cert() const {
+ // If |ssl_server_name_| is non-empty we're in client/server mode and don't
+ // need to verify a peer certificate.
+ return ssl_server_name_.empty() && client_auth_enabled() &&
pthatcher1 2016/07/22 18:58:27 set_client_auth_enabled() is never called by anyth
Taylor Brandstetter 2016/07/25 23:54:53 See above.
+ !certificate_verified_;
+ }
+
+ bool have_peer_certificate_digest() const {
+ return peer_certificate_digest_algorithm_.size() &&
mattdr-at-webrtc.org 2016/07/21 08:04:23 personal preference: !xyz.empty()
Taylor Brandstetter 2016/07/22 18:52:20 rtc::Buffer didn't have an "empty" method so I add
pthatcher1 2016/07/22 18:58:27 +1
+ peer_certificate_digest_value_.size();
+ }
+
SSLState state_;
SSLRole role_;
int ssl_error_code_; // valid when state_ == SSL_ERROR or SSL_CLOSED
@@ -185,6 +204,7 @@ class OpenSSLStreamAdapter : public SSLStreamAdapter {
SSL* ssl_;
SSL_CTX* ssl_ctx_;
+ SSLTopology topology_ = TOPOLOGY_UNKNOWN;
mattdr-at-webrtc.org 2016/07/21 08:04:23 It's nice to be explicit, but in a way this is dup
Taylor Brandstetter 2016/07/22 18:52:20 You're very right. I replaced every "topology" che
// Our key and certificate, mostly useful in peer-to-peer mode.
std::unique_ptr<OpenSSLIdentity> identity_;
// in traditional mode, the server name that the server's certificate
@@ -197,6 +217,7 @@ class OpenSSLStreamAdapter : public SSLStreamAdapter {
// the peer must present.
Buffer peer_certificate_digest_value_;
std::string peer_certificate_digest_algorithm_;
+ bool certificate_verified_ = false;
pthatcher1 2016/07/22 18:58:27 Since the method that changes this is VerifyPeerCe
Taylor Brandstetter 2016/07/25 23:54:53 Done.
// OpenSSLAdapter::custom_verify_callback_ result
pthatcher1 2016/07/22 18:58:27 Would it make sense to make everything "remote" as
Taylor Brandstetter 2016/07/25 23:54:53 What about the PeerConnection? :) Anyway you're p
bool custom_verification_succeeded_;
« no previous file with comments | « no previous file | webrtc/base/opensslstreamadapter.cc » ('j') | webrtc/base/opensslstreamadapter.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698