2015-01-06 14:20:05 +00:00
|
|
|
/*
|
|
|
|
* synergy -- mouse and keyboard sharing utility
|
2015-01-09 13:46:35 +00:00
|
|
|
* Copyright (C) 2015 Synergy Si Ltd.
|
2015-01-06 14:20:05 +00:00
|
|
|
*
|
|
|
|
* This package is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
2015-05-03 02:33:52 +00:00
|
|
|
* found in the file LICENSE that should have accompanied this file.
|
2015-01-06 14:20:05 +00:00
|
|
|
*
|
|
|
|
* This package is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2015-01-14 17:24:45 +00:00
|
|
|
#include "net/TCPSocket.h"
|
2015-01-29 15:40:30 +00:00
|
|
|
#include "net/XSocket.h"
|
2015-01-14 17:24:45 +00:00
|
|
|
|
|
|
|
class IEventQueue;
|
|
|
|
class SocketMultiplexer;
|
2015-01-26 13:23:11 +00:00
|
|
|
class ISocketMultiplexerJob;
|
2015-01-14 17:24:45 +00:00
|
|
|
|
|
|
|
struct Ssl;
|
2015-01-06 14:20:05 +00:00
|
|
|
|
2015-01-14 17:24:45 +00:00
|
|
|
//! Secure socket
|
2015-01-06 14:20:05 +00:00
|
|
|
/*!
|
2015-01-14 17:24:45 +00:00
|
|
|
A secure socket using SSL.
|
2015-01-06 14:20:05 +00:00
|
|
|
*/
|
2015-01-14 17:24:45 +00:00
|
|
|
class SecureSocket : public TCPSocket {
|
2015-01-06 14:20:05 +00:00
|
|
|
public:
|
2015-01-14 17:24:45 +00:00
|
|
|
SecureSocket(IEventQueue* events, SocketMultiplexer* socketMultiplexer);
|
|
|
|
SecureSocket(IEventQueue* events,
|
|
|
|
SocketMultiplexer* socketMultiplexer,
|
|
|
|
ArchSocket socket);
|
2015-01-09 13:46:35 +00:00
|
|
|
~SecureSocket();
|
2015-01-06 14:20:05 +00:00
|
|
|
|
2015-01-29 15:40:30 +00:00
|
|
|
// ISocket overrides
|
|
|
|
void close();
|
|
|
|
|
2015-01-26 13:23:11 +00:00
|
|
|
void secureConnect();
|
|
|
|
void secureAccept();
|
2015-01-29 15:40:30 +00:00
|
|
|
bool isReady() const { return m_secureReady; }
|
2015-01-26 13:23:11 +00:00
|
|
|
bool isSecureReady();
|
|
|
|
bool isSecure() { return true; }
|
|
|
|
UInt32 secureRead(void* buffer, UInt32 n);
|
|
|
|
UInt32 secureWrite(const void* buffer, UInt32 n);
|
2015-01-14 17:24:45 +00:00
|
|
|
void initSsl(bool server);
|
2015-04-14 13:03:43 +00:00
|
|
|
bool loadCertificates(String& CertFile);
|
2015-01-06 14:20:05 +00:00
|
|
|
|
|
|
|
private:
|
2015-01-14 17:24:45 +00:00
|
|
|
// SSL
|
|
|
|
void initContext(bool server);
|
|
|
|
void createSSL();
|
2015-01-26 13:23:11 +00:00
|
|
|
bool secureAccept(int s);
|
|
|
|
bool secureConnect(int s);
|
2015-04-10 13:07:53 +00:00
|
|
|
bool showCertificate();
|
2015-05-20 19:08:25 +00:00
|
|
|
void checkResult(int n, bool& fatal, int& retry);
|
2015-04-10 13:07:53 +00:00
|
|
|
void showError(const char* reason = NULL);
|
2015-04-14 12:44:10 +00:00
|
|
|
String getError();
|
2015-04-02 10:56:51 +00:00
|
|
|
void disconnect();
|
2015-04-15 12:06:49 +00:00
|
|
|
void formatFingerprint(String& fingerprint,
|
|
|
|
bool hex = true,
|
|
|
|
bool separator = true);
|
2015-04-02 10:56:51 +00:00
|
|
|
bool verifyCertFingerprint();
|
2015-01-06 14:20:05 +00:00
|
|
|
|
2015-01-26 13:23:11 +00:00
|
|
|
ISocketMultiplexerJob*
|
|
|
|
serviceConnect(ISocketMultiplexerJob*,
|
|
|
|
bool, bool, bool);
|
|
|
|
|
|
|
|
ISocketMultiplexerJob*
|
|
|
|
serviceAccept(ISocketMultiplexerJob*,
|
|
|
|
bool, bool, bool);
|
|
|
|
|
2015-01-06 14:20:05 +00:00
|
|
|
private:
|
2015-01-09 13:46:35 +00:00
|
|
|
Ssl* m_ssl;
|
2015-01-26 13:23:11 +00:00
|
|
|
bool m_secureReady;
|
2015-01-06 14:20:05 +00:00
|
|
|
};
|