diff options
author | Anthony Neal <aneal@zeroc.com> | 2002-10-29 18:44:20 +0000 |
---|---|---|
committer | Anthony Neal <aneal@zeroc.com> | 2002-10-29 18:44:20 +0000 |
commit | 8597953fa6e03ab064f536ce7056628fb54b8674 (patch) | |
tree | c4c2129f39ca2cfa99f1f8335ee12f534f32fff4 /cpp/src/IceSSL/SslTransceiver.cpp | |
parent | Minor fixes. (diff) | |
download | ice-8597953fa6e03ab064f536ce7056628fb54b8674.tar.bz2 ice-8597953fa6e03ab064f536ce7056628fb54b8674.tar.xz ice-8597953fa6e03ab064f536ce7056628fb54b8674.zip |
Implemented connect-time handshaking.
Diffstat (limited to 'cpp/src/IceSSL/SslTransceiver.cpp')
-rw-r--r-- | cpp/src/IceSSL/SslTransceiver.cpp | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/cpp/src/IceSSL/SslTransceiver.cpp b/cpp/src/IceSSL/SslTransceiver.cpp index 30ae5ba54b2..334fc554295 100644 --- a/cpp/src/IceSSL/SslTransceiver.cpp +++ b/cpp/src/IceSSL/SslTransceiver.cpp @@ -273,11 +273,60 @@ IceSSL::SslTransceiver::toString() const } void +IceSSL::SslTransceiver::forceHandshake() +{ + int retryCount = 0; + + while(retryCount < _handshakeRetries) + { + ++retryCount; + + try + { + if(handshake(_handshakeReadTimeout) > 0) + { + // Handshake complete. + break; + } + } + catch(TimeoutException) + { + // Do nothing. + } + } + + if(retryCount >= _handshakeRetries) + { + if(_traceLevels->security >= IceSSL::SECURITY_WARNINGS) + { + Trace out(_logger, _traceLevels->securityCat); + out << "Handshake retry maximum reached.\n"; + out << fdToString(SSL_get_fd(_sslConnection)); + } + + // If the handshake fails, the connection failed. + ConnectFailedException ex(__FILE__, __LINE__); +#ifdef _WIN32 + ex.error = WSAECONNREFUSED; +#else + ex.error = ECONNREFUSED; +#endif + throw ex; + } +} + +void IceSSL::SslTransceiver::setHandshakeReadTimeout(int timeout) { _handshakeReadTimeout = timeout; } +void +IceSSL::SslTransceiver::setHandshakeRetries(int retries) +{ + _handshakeRetries = retries; +} + IceSSL::SslTransceiverPtr IceSSL::SslTransceiver::getTransceiver(SSL* sslPtr) { @@ -958,8 +1007,8 @@ IceSSL::SslTransceiver::SslTransceiver(const OpenSSLPluginIPtr& plugin, _initWantRead = 0; _initWantWrite = 0; - // None configured, default to indicated timeout _handshakeReadTimeout = 0; + _handshakeRetries = 0; // Set up the SSL to be able to refer back to our connection object. addTransceiver(_sslConnection, this); |