bool SSLSocket::waitAccepted(uint64_t millis) { if(!ssl) { if(!Socket::waitAccepted(millis)) { return false; } ssl.reset(SSL_new(ctx)); if(!ssl) checkSSL(-1); if(!verifyData) { SSL_set_verify(ssl, SSL_VERIFY_NONE, NULL); } else SSL_set_ex_data(ssl, CryptoManager::idxVerifyData, verifyData.get()); checkSSL(SSL_set_fd(ssl, static_cast<int>(getSock()))); } if(SSL_is_init_finished(ssl)) { return true; } while(true) { int ret = SSL_accept(ssl); if(ret == 1) { dcdebug("Connected to SSL client using %s\n", SSL_get_cipher(ssl)); return true; } if(!waitWant(ret, millis)) { return false; } } }
bool SSLSocket::waitConnected(uint64_t millis) { if(!ssl) { if(!Socket::waitConnected(millis)) { return false; } ssl.reset(SSL_new(ctx)); if(!ssl) checkSSL(-1); checkSSL(SSL_set_fd(ssl, sock)); } if(SSL_is_init_finished(ssl)) { return true; } while(true) { // OpenSSL needs server handshake for NAT traversal int ret = ssl->server ? SSL_accept(ssl) : SSL_connect(ssl); if(ret == 1) { dcdebug("Connected to SSL server using %s as %s\n", SSL_get_cipher(ssl), ssl->server?"server":"client"); #ifndef HEADER_OPENSSLV_H finished = true; #endif return true; } if(!waitWant(ret, millis)) { return false; } } }
bool SSLSocket::waitAccepted(uint64_t millis) { if(!ssl) { if(!Socket::waitAccepted(millis)) { return false; } ssl.reset(SSL_new(ctx)); if(!ssl) checkSSL(-1); checkSSL(SSL_set_fd(ssl, sock)); } if(SSL_is_init_finished(ssl)) { return true; } while(true) { int ret = SSL_accept(ssl); if(ret == 1) { dcdebug("Connected to SSL client using %s\n", SSL_get_cipher(ssl)); #ifndef HEADER_OPENSSLV_H finished = true; #endif return true; } if(!waitWant(ret, millis)) { return false; } } }
bool SSLSocket::waitAccepted(uint32_t millis) { if(!ssl) { if(!Socket::waitAccepted(millis)) { return false; } ssl.reset(SSL_new(ctx)); if(!ssl) checkSSL(-1); checkSSL(SSL_set_fd(ssl, getSock())); } if(SSL_is_init_finished(ssl)) { return true; } while(true) { int ret = SSL_accept(ssl); if(ret == 1) { dcdebug("Connected to SSL client using %s\n", SSL_get_cipher(ssl)); return true; } if(!waitWant(ret, millis)) { return false; } } }