Support for DTLS in OpenSSLAdapter
1) Added SetMode() to SSLAdapter and OpenSSLAdapter so the mode can be set to
SSL_MODE_DTLS
2) OpenSSLAdapter overrides SendTo() and RecvFrom() to handle calls from
TurnPort via AsyncUdpSocket
3) OpenSSLAdapter derives from MessageHandler to implement an internal DTLS
timer
4) Updated SSLAdapter unit tests
BUG=
R=juberti@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/19059004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7981 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@ -12,6 +12,8 @@
|
||||
#define WEBRTC_BASE_OPENSSLADAPTER_H__
|
||||
|
||||
#include <string>
|
||||
#include "webrtc/base/messagehandler.h"
|
||||
#include "webrtc/base/messagequeue.h"
|
||||
#include "webrtc/base/ssladapter.h"
|
||||
|
||||
typedef struct ssl_st SSL;
|
||||
@ -22,7 +24,7 @@ namespace rtc {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class OpenSSLAdapter : public SSLAdapter {
|
||||
class OpenSSLAdapter : public SSLAdapter, public MessageHandler {
|
||||
public:
|
||||
static bool InitializeSSL(VerificationCallback callback);
|
||||
static bool InitializeSSLThread();
|
||||
@ -31,9 +33,12 @@ public:
|
||||
OpenSSLAdapter(AsyncSocket* socket);
|
||||
virtual ~OpenSSLAdapter();
|
||||
|
||||
virtual void SetMode(SSLMode mode);
|
||||
virtual int StartSSL(const char* hostname, bool restartable);
|
||||
virtual int Send(const void* pv, size_t cb);
|
||||
virtual int SendTo(const void* pv, size_t cb, const SocketAddress& addr);
|
||||
virtual int Recv(void* pv, size_t cb);
|
||||
virtual int RecvFrom(void* pv, size_t cb, SocketAddress* paddr);
|
||||
virtual int Close();
|
||||
|
||||
// Note that the socket returns ST_CONNECTING while SSL is being negotiated.
|
||||
@ -50,11 +55,15 @@ private:
|
||||
SSL_NONE, SSL_WAIT, SSL_CONNECTING, SSL_CONNECTED, SSL_ERROR
|
||||
};
|
||||
|
||||
enum { MSG_TIMEOUT };
|
||||
|
||||
int BeginSSL();
|
||||
int ContinueSSL();
|
||||
void Error(const char* context, int err, bool signal = true);
|
||||
void Cleanup();
|
||||
|
||||
virtual void OnMessage(Message* msg);
|
||||
|
||||
static bool VerifyServerName(SSL* ssl, const char* host,
|
||||
bool ignore_bad_cert);
|
||||
bool SSLPostConnectionCheck(SSL* ssl, const char* host);
|
||||
@ -66,7 +75,7 @@ private:
|
||||
friend class OpenSSLStreamAdapter; // for custom_verify_callback_;
|
||||
|
||||
static bool ConfigureTrustedRootCertificates(SSL_CTX* ctx);
|
||||
static SSL_CTX* SetupSSLContext();
|
||||
SSL_CTX* SetupSSLContext();
|
||||
|
||||
SSLState state_;
|
||||
bool ssl_read_needs_write_;
|
||||
@ -77,6 +86,8 @@ private:
|
||||
SSL* ssl_;
|
||||
SSL_CTX* ssl_ctx_;
|
||||
std::string ssl_host_name_;
|
||||
// Do DTLS or not
|
||||
SSLMode ssl_mode_;
|
||||
|
||||
bool custom_verification_succeeded_;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user