MCPcopy Create free account
hub / github.com/apache/thrift / initializeHandshake

Method initializeHandshake

lib/cpp/src/thrift/transport/TSSLSocket.cpp:626–711  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

624}
625
626void TSSLSocket::initializeHandshake() {
627 if (!TSocket::isOpen()) {
628 throw TTransportException(TTransportException::NOT_OPEN);
629 }
630 if (checkHandshake()) {
631 return;
632 }
633
634 if (ssl_ == nullptr) {
635 initializeHandshakeParams();
636 }
637
638 int rc;
639 int errno_copy = 0;
640 int error = 0;
641 if (server()) {
642 do {
643 rc = SSL_accept(ssl_);
644 if (rc <= 0) {
645 errno_copy = THRIFT_GET_SOCKET_ERROR;
646 error = SSL_get_error(ssl_, rc);
647 switch (error) {
648 case SSL_ERROR_SYSCALL:
649 if ((errno_copy != THRIFT_EINTR)
650 && (errno_copy != THRIFT_EAGAIN)) {
651 break;
652 }
653 // fallthrough
654 case SSL_ERROR_WANT_READ:
655 case SSL_ERROR_WANT_WRITE:
656 if (isLibeventSafe()) {
657 return;
658 }
659 else {
660 // repeat operation
661 // in the case of SSL_ERROR_SYSCALL we want to wait for an write/read event again
662 waitForEvent(error == SSL_ERROR_WANT_READ);
663 rc = 2;
664 }
665 default:;// do nothing
666 }
667 }
668 } while (rc == 2);
669 } else {
670 // OpenSSL < 0.9.8f does not have SSL_set_tlsext_host_name()
671 #if defined(SSL_set_tlsext_host_name)
672 // set the SNI hostname
673 SSL_set_tlsext_host_name(ssl_, getHost().c_str());
674 #endif
675 do {
676 rc = SSL_connect(ssl_);
677 if (rc <= 0) {
678 errno_copy = THRIFT_GET_SOCKET_ERROR;
679 error = SSL_get_error(ssl_, rc);
680 switch (error) {
681 case SSL_ERROR_SYSCALL:
682 if ((errno_copy != THRIFT_EINTR)
683 && (errno_copy != THRIFT_EAGAIN)) {

Callers

nothing calls this directly

Calls 3

buildErrorsFunction · 0.85
TSSLExceptionClass · 0.85
TTransportExceptionClass · 0.70

Tested by

no test coverage detected