removed client connection when SSL handshake failed #4313

This commit is contained in:
XinyuHou 2015-02-02 14:18:34 +00:00
parent ad230d46e6
commit 10e6b5ad63
4 changed files with 22 additions and 3 deletions

View File

@ -62,7 +62,7 @@ public:
protected:
ArchSocket getSocket() { return m_socket; }
IEventQueue* getEvents() { return m_events; }
virtual bool isSecureReady() { return false; }
virtual bool isSecure() { return false; }
virtual UInt32 secureRead(void* buffer, UInt32) { return 0; }
@ -76,11 +76,12 @@ protected:
Mutex& getMutex() { return m_mutex; }
void sendEvent(Event::Type);
private:
void init();
void sendConnectionFailedEvent(const char*);
void sendEvent(Event::Type);
void onConnected();
void onInputShutdown();
void onOutputShutdown();

View File

@ -308,7 +308,8 @@ SecureSocket::checkResult(int n)
case SSL_ERROR_SSL:
// a failure in the SSL library occurred
LOG((CLOG_DEBUG2 "SSL_ERROR_SSL"));
throwError("Secure socket SSL error");
sendEvent(getEvents()->forIStream().inputShutdown());
showError();
break;
default:

View File

@ -188,6 +188,7 @@ ClientListener::handleUnknownClient(const Event&, void* vclient)
// get the real client proxy and install it
ClientProxy* client = unknownClient->orphanClientProxy();
bool handshakeOk = true;
if (client != NULL) {
// handshake was successful
m_waitingClients.push_back(client);
@ -199,12 +200,25 @@ ClientListener::handleUnknownClient(const Event&, void* vclient)
&ClientListener::handleClientDisconnected,
client));
}
else {
handshakeOk = false;
}
// now finished with unknown client
m_events->removeHandler(m_events->forClientProxyUnknown().success(), client);
m_events->removeHandler(m_events->forClientProxyUnknown().failure(), client);
m_newClients.erase(unknownClient);
PacketStreamFilter* streamFileter = dynamic_cast<PacketStreamFilter*>(unknownClient->getStream());
IDataSocket* socket = NULL;
if (streamFileter != NULL) {
socket = dynamic_cast<IDataSocket*>(streamFileter->getStream());
}
delete unknownClient;
if (m_useSecureNetwork && !handshakeOk) {
deleteSocket(socket);
}
}
void

View File

@ -43,6 +43,9 @@ public:
*/
ClientProxy* orphanClientProxy();
//! Get the stream
synergy::IStream* getStream() { return m_stream; }
//@}
private: