| 158 | } |
| 159 | |
| 160 | void client(apache::thrift::transport::SSLProtocol protocol) |
| 161 | { |
| 162 | try |
| 163 | { |
| 164 | shared_ptr<TSSLSocketFactory> pClientSocketFactory; |
| 165 | shared_ptr<TSSLSocket> pClientSocket; |
| 166 | |
| 167 | try |
| 168 | { |
| 169 | pClientSocketFactory.reset(new TSSLSocketFactory(static_cast<apache::thrift::transport::SSLProtocol>(protocol))); |
| 170 | pClientSocketFactory->authenticate(true); |
| 171 | #if OPENSSL_VERSION_NUMBER >= 0x10100000L |
| 172 | // OpenSSL 1.1.0 introduced @SECLEVEL. Modern distributions limit TLS 1.0/1.1 |
| 173 | // to @SECLEVEL=0 or 1, so specify it to test all combinations. |
| 174 | pClientSocketFactory->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@SECLEVEL=0"); |
| 175 | #endif |
| 176 | pClientSocketFactory->loadCertificate(certFile("client.crt").string().c_str()); |
| 177 | pClientSocketFactory->loadPrivateKey(certFile("client.key").string().c_str()); |
| 178 | pClientSocketFactory->loadTrustedCertificates(certFile("CA.pem").string().c_str()); |
| 179 | pClientSocket = pClientSocketFactory->createSocket("localhost", mPort); |
| 180 | pClientSocket->open(); |
| 181 | |
| 182 | uint8_t buf[3]; |
| 183 | buf[0] = 0; |
| 184 | buf[1] = 0; |
| 185 | BOOST_CHECK_EQUAL(2, pClientSocket->read(&buf[0], 2)); |
| 186 | BOOST_CHECK_EQUAL(0, memcmp(&buf[0], "OK", 2)); |
| 187 | mConnected = true; |
| 188 | } |
| 189 | catch (apache::thrift::transport::TTransportException& ex) |
| 190 | { |
| 191 | boost::mutex::scoped_lock lock(gMutex); |
| 192 | BOOST_TEST_MESSAGE(boost::format("CLI %1% Exception: %2%") % boost::this_thread::get_id() % ex.what()); |
| 193 | } |
| 194 | |
| 195 | if (pClientSocket) |
| 196 | { |
| 197 | pClientSocket->close(); |
| 198 | pClientSocket.reset(); |
| 199 | } |
| 200 | } |
| 201 | catch (std::exception& ex) |
| 202 | { |
| 203 | BOOST_FAIL(boost::format("%1%: %2%") % typeid(ex).name() % ex.what()); |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | static const char *protocol2str(size_t protocol) |
| 208 | { |
nothing calls this directly
no test coverage detected