| OLD | NEW |
| 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 |
| 11 #ifndef WEBRTC_BASE_SSLADAPTER_H_ | 11 #ifndef WEBRTC_BASE_SSLADAPTER_H_ |
| 12 #define WEBRTC_BASE_SSLADAPTER_H_ | 12 #define WEBRTC_BASE_SSLADAPTER_H_ |
| 13 | 13 |
| 14 #include "webrtc/base/asyncsocket.h" | |
| 15 #include "webrtc/base/sslstreamadapter.h" | |
| 16 | 14 |
| 17 namespace rtc { | 15 // This header is deprecated and is just left here temporarily during |
| 18 | 16 // refactoring. See https://bugs.webrtc.org/7634 for more details. |
| 19 /////////////////////////////////////////////////////////////////////////////// | 17 #include "webrtc/rtc_base/ssladapter.h" |
| 20 | |
| 21 class SSLAdapter : public AsyncSocketAdapter { | |
| 22 public: | |
| 23 explicit SSLAdapter(AsyncSocket* socket) | |
| 24 : AsyncSocketAdapter(socket), ignore_bad_cert_(false) { } | |
| 25 | |
| 26 bool ignore_bad_cert() const { return ignore_bad_cert_; } | |
| 27 void set_ignore_bad_cert(bool ignore) { ignore_bad_cert_ = ignore; } | |
| 28 | |
| 29 // Do DTLS or TLS (default is TLS, if unspecified) | |
| 30 virtual void SetMode(SSLMode mode) = 0; | |
| 31 | |
| 32 // StartSSL returns 0 if successful. | |
| 33 // If StartSSL is called while the socket is closed or connecting, the SSL | |
| 34 // negotiation will begin as soon as the socket connects. | |
| 35 virtual int StartSSL(const char* hostname, bool restartable) = 0; | |
| 36 | |
| 37 // Create the default SSL adapter for this platform. On failure, returns null | |
| 38 // and deletes |socket|. Otherwise, the returned SSLAdapter takes ownership | |
| 39 // of |socket|. | |
| 40 static SSLAdapter* Create(AsyncSocket* socket); | |
| 41 | |
| 42 private: | |
| 43 // If true, the server certificate need not match the configured hostname. | |
| 44 bool ignore_bad_cert_; | |
| 45 }; | |
| 46 | |
| 47 /////////////////////////////////////////////////////////////////////////////// | |
| 48 | |
| 49 typedef bool (*VerificationCallback)(void* cert); | |
| 50 | |
| 51 // Call this on the main thread, before using SSL. | |
| 52 // Call CleanupSSLThread when finished with SSL. | |
| 53 bool InitializeSSL(VerificationCallback callback = nullptr); | |
| 54 | |
| 55 // Call to initialize additional threads. | |
| 56 bool InitializeSSLThread(); | |
| 57 | |
| 58 // Call to cleanup additional threads, and also the main thread. | |
| 59 bool CleanupSSL(); | |
| 60 | |
| 61 /////////////////////////////////////////////////////////////////////////////// | |
| 62 | |
| 63 } // namespace rtc | |
| 64 | 18 |
| 65 #endif // WEBRTC_BASE_SSLADAPTER_H_ | 19 #endif // WEBRTC_BASE_SSLADAPTER_H_ |
| OLD | NEW |