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

Side by Side Diff: webrtc/base/opensslstreamadapter.h

Issue 2352863003: Revert of Allow the DTLS fingerprint verification to occur after the handshake. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 3 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 | webrtc/base/opensslstreamadapter.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 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 56
57 class OpenSSLStreamAdapter : public SSLStreamAdapter { 57 class OpenSSLStreamAdapter : public SSLStreamAdapter {
58 public: 58 public:
59 explicit OpenSSLStreamAdapter(StreamInterface* stream); 59 explicit OpenSSLStreamAdapter(StreamInterface* stream);
60 ~OpenSSLStreamAdapter() override; 60 ~OpenSSLStreamAdapter() override;
61 61
62 void SetIdentity(SSLIdentity* identity) override; 62 void SetIdentity(SSLIdentity* identity) override;
63 63
64 // Default argument is for compatibility 64 // Default argument is for compatibility
65 void SetServerRole(SSLRole role = SSL_SERVER) override; 65 void SetServerRole(SSLRole role = SSL_SERVER) override;
66 SSLPeerCertificateDigestError SetPeerCertificateDigest( 66 bool SetPeerCertificateDigest(const std::string& digest_alg,
67 const std::string& digest_alg, 67 const unsigned char* digest_val,
68 const unsigned char* digest_val, 68 size_t digest_len) override;
69 size_t digest_len) override;
70 69
71 std::unique_ptr<SSLCertificate> GetPeerCertificate() const override; 70 std::unique_ptr<SSLCertificate> GetPeerCertificate() const override;
72 71
73 // Goes from state SSL_NONE to either SSL_CONNECTING or SSL_WAIT, depending 72 // Goes from state SSL_NONE to either SSL_CONNECTING or SSL_WAIT, depending
74 // on whether the underlying stream is already open or not. 73 // on whether the underlying stream is already open or not.
75 int StartSSL() override; 74 int StartSSL() override;
76 void SetMode(SSLMode mode) override; 75 void SetMode(SSLMode mode) override;
77 void SetMaxProtocolVersion(SSLProtocolVersion version) override; 76 void SetMaxProtocolVersion(SSLProtocolVersion version) override;
78 77
79 StreamResult Read(void* data, 78 StreamResult Read(void* data,
(...skipping 19 matching lines...) Expand all
99 const uint8_t* context, 98 const uint8_t* context,
100 size_t context_len, 99 size_t context_len,
101 bool use_context, 100 bool use_context,
102 uint8_t* result, 101 uint8_t* result,
103 size_t result_len) override; 102 size_t result_len) override;
104 103
105 // DTLS-SRTP interface 104 // DTLS-SRTP interface
106 bool SetDtlsSrtpCryptoSuites(const std::vector<int>& crypto_suites) override; 105 bool SetDtlsSrtpCryptoSuites(const std::vector<int>& crypto_suites) override;
107 bool GetDtlsSrtpCryptoSuite(int* crypto_suite) override; 106 bool GetDtlsSrtpCryptoSuite(int* crypto_suite) override;
108 107
109 bool IsTlsConnected() override;
110
111 // Capabilities interfaces 108 // Capabilities interfaces
112 static bool HaveDtls(); 109 static bool HaveDtls();
113 static bool HaveDtlsSrtp(); 110 static bool HaveDtlsSrtp();
114 static bool HaveExporter(); 111 static bool HaveExporter();
115 static bool IsBoringSsl(); 112 static bool IsBoringSsl();
116 113
117 static bool IsAcceptableCipher(int cipher, KeyType key_type); 114 static bool IsAcceptableCipher(int cipher, KeyType key_type);
118 static bool IsAcceptableCipher(const std::string& cipher, KeyType key_type); 115 static bool IsAcceptableCipher(const std::string& cipher, KeyType key_type);
119 116
120 protected: 117 protected:
(...skipping 22 matching lines...) Expand all
143 int BeginSSL(); 140 int BeginSSL();
144 // Perform SSL negotiation steps. 141 // Perform SSL negotiation steps.
145 int ContinueSSL(); 142 int ContinueSSL();
146 143
147 // Error handler helper. signal is given as true for errors in 144 // Error handler helper. signal is given as true for errors in
148 // asynchronous contexts (when an error method was not returned 145 // asynchronous contexts (when an error method was not returned
149 // through some other method), and in that case an SE_CLOSE event is 146 // through some other method), and in that case an SE_CLOSE event is
150 // raised on the stream with the specified error. 147 // raised on the stream with the specified error.
151 // A 0 error means a graceful close, otherwise there is not really enough 148 // A 0 error means a graceful close, otherwise there is not really enough
152 // context to interpret the error code. 149 // context to interpret the error code.
153 // |alert| indicates an alert description (one of the SSL_AD constants) to 150 void Error(const char* context, int err, bool signal);
154 // send to the remote endpoint when closing the association. If 0, a normal 151 void Cleanup();
155 // shutdown will be performed.
156 void Error(const char* context, int err, uint8_t alert, bool signal);
157 void Cleanup(uint8_t alert);
158 152
159 // Override MessageHandler 153 // Override MessageHandler
160 void OnMessage(Message* msg) override; 154 void OnMessage(Message* msg) override;
161 155
162 // Flush the input buffers by reading left bytes (for DTLS) 156 // Flush the input buffers by reading left bytes (for DTLS)
163 void FlushInput(unsigned int left); 157 void FlushInput(unsigned int left);
164 158
165 // SSL library configuration 159 // SSL library configuration
166 SSL_CTX* SetupSSLContext(); 160 SSL_CTX* SetupSSLContext();
167 // Verify the peer certificate matches the signaled digest. 161 // SSL verification check
168 bool VerifyPeerCertificate(); 162 bool SSLPostConnectionCheck(SSL* ssl,
163 const X509* peer_cert,
164 const std::string& peer_digest);
169 // SSL certification verification error handler, called back from 165 // SSL certification verification error handler, called back from
170 // the openssl library. Returns an int interpreted as a boolean in 166 // the openssl library. Returns an int interpreted as a boolean in
171 // the C style: zero means verification failure, non-zero means 167 // the C style: zero means verification failure, non-zero means
172 // passed. 168 // passed.
173 static int SSLVerifyCallback(int ok, X509_STORE_CTX* store); 169 static int SSLVerifyCallback(int ok, X509_STORE_CTX* store);
174 170
175 bool waiting_to_verify_peer_certificate_cert() const {
176 return client_auth_enabled() && !peer_certificate_verified_;
177 }
178
179 bool has_peer_certificate_digest() const {
180 return !peer_certificate_digest_algorithm_.empty() &&
181 !peer_certificate_digest_value_.empty();
182 }
183
184 SSLState state_; 171 SSLState state_;
185 SSLRole role_; 172 SSLRole role_;
186 int ssl_error_code_; // valid when state_ == SSL_ERROR or SSL_CLOSED 173 int ssl_error_code_; // valid when state_ == SSL_ERROR or SSL_CLOSED
187 // Whether the SSL negotiation is blocked on needing to read or 174 // Whether the SSL negotiation is blocked on needing to read or
188 // write to the wrapped stream. 175 // write to the wrapped stream.
189 bool ssl_read_needs_write_; 176 bool ssl_read_needs_write_;
190 bool ssl_write_needs_read_; 177 bool ssl_write_needs_read_;
191 178
192 SSL* ssl_; 179 SSL* ssl_;
193 SSL_CTX* ssl_ctx_; 180 SSL_CTX* ssl_ctx_;
194 181
195 // Our key and certificate. 182 // Our key and certificate.
196 std::unique_ptr<OpenSSLIdentity> identity_; 183 std::unique_ptr<OpenSSLIdentity> identity_;
197 // The certificate that the peer presented. Initially null, until the 184 // The certificate that the peer presented. Initially null, until the
198 // connection is established. 185 // connection is established.
199 std::unique_ptr<OpenSSLCertificate> peer_certificate_; 186 std::unique_ptr<OpenSSLCertificate> peer_certificate_;
200 bool peer_certificate_verified_ = false;
201 // The digest of the certificate that the peer must present. 187 // The digest of the certificate that the peer must present.
202 Buffer peer_certificate_digest_value_; 188 Buffer peer_certificate_digest_value_;
203 std::string peer_certificate_digest_algorithm_; 189 std::string peer_certificate_digest_algorithm_;
204 190
205 // The DtlsSrtp ciphers 191 // The DtlsSrtp ciphers
206 std::string srtp_ciphers_; 192 std::string srtp_ciphers_;
207 193
208 // Do DTLS or not 194 // Do DTLS or not
209 SSLMode ssl_mode_; 195 SSLMode ssl_mode_;
210 196
211 // Max. allowed protocol version 197 // Max. allowed protocol version
212 SSLProtocolVersion ssl_max_version_; 198 SSLProtocolVersion ssl_max_version_;
213 }; 199 };
214 200
215 ///////////////////////////////////////////////////////////////////////////// 201 /////////////////////////////////////////////////////////////////////////////
216 202
217 } // namespace rtc 203 } // namespace rtc
218 204
219 #endif // WEBRTC_BASE_OPENSSLSTREAMADAPTER_H__ 205 #endif // WEBRTC_BASE_OPENSSLSTREAMADAPTER_H__
OLDNEW
« no previous file with comments | « no previous file | webrtc/base/opensslstreamadapter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698