@@ -68,7 +68,7 @@ class SSLTCPTest : public ::testing::Test
6868
6969 virtual void SetUp ()
7070 {
71- m_pSSLTCPClient.reset (new CTCPSSLClient (PRINT_LOG, ASecureSocket::OpenSSLProtocol::SSL_V3 ));
71+ m_pSSLTCPClient.reset (new CTCPSSLClient (PRINT_LOG));
7272 }
7373
7474 virtual void TearDown ()
@@ -229,30 +229,57 @@ TEST_F(SSLTCPTest, TestLoopback)
229229 char szRcvBuffer[14 ] = {};
230230 ASecureSocket::SSLSocket ConnectedClient;
231231
232- ASSERT_NO_THROW (m_pSSLTCPServer.reset (new CTCPSSLServer (PRINT_LOG, " 4242" ,
233- ASecureSocket::OpenSSLProtocol::SSL_V3)));
232+ ASSERT_NO_THROW (m_pSSLTCPServer.reset (new CTCPSSLServer (PRINT_LOG, " 4242" )));
234233
235- m_pSSLTCPServer->SetSSLCertFile (" C:\\ TestOpenSSL\\ site.cert" );
236- // m_pSSLTCPServer->SetSSLCerthAuth("C:\\TestOpenSSL\\CAfile.pem");
234+ m_pSSLTCPServer->SetSSLCertFile (" site.cert" );
235+ m_pSSLTCPServer->SetSSLCerthAuth (" CAfile.pem" );
236+ m_pSSLTCPServer->SetSSLKeyFile (" privkey.pem" );
237237
238+ #ifdef WINDOWS
238239 std::future<bool > futListen = std::async ([&]() -> bool
239240 {
240241 // give time to let the server object reach the accept instruction.
241242 #ifdef LINUX
242- for (int iSec = 0 ; iSec < 5 ; ++iSec)
243- usleep (1000000 );
243+ // for (int iSec = 0; iSec < 5000 ; ++iSec)
244+ // usleep(1000 );
244245 #else
245246 for (int iSec = 0 ; iSec < 5 ; ++iSec)
246247 Sleep (1000 );
247248 #endif
248249
249- m_pSSLTCPClient->SetSSLCerthAuth (" C:\\ TestOpenSSL\\ CAfile.pem" );
250+ // m_pSSLTCPClient->SetSSLCerthAuth("C:\\TestOpenSSL\\CAfile.pem");
250251 return m_pSSLTCPClient->Connect (" localhost" , " 4242" );
251252 });
253+ #else
254+ auto ConnectTask = [&]() -> bool
255+ {
256+ // give time to let the server object reach the accept instruction.
257+ #ifdef LINUX
258+ std::cout << " ** Connect task : delay\n " ;
259+ for (int iSec = 0 ; iSec < 5000 ; ++iSec)
260+ usleep (1000 );
261+ #else
262+ for (int iSec = 0 ; iSec < 5 ; ++iSec)
263+ Sleep (1000 );
264+ #endif
265+ std::cout << " ** Connect task : begin connect\n " ;
266+ m_pSSLTCPClient->SetSSLCerthAuth (" CAfile.pem" );
267+ m_pSSLTCPClient->SetSSLKeyFile (" privkey.pem" );
268+ bool bRet = m_pSSLTCPClient->Connect (" localhost" , " 4242" );
269+ std::cout << " ** Connect task : end connect\n " ;
270+ return bRet;
271+ };
272+ std::thread ConnectThread (ConnectTask);
273+ #endif
252274
253275 m_pSSLTCPServer->Listen (ConnectedClient);
254276
277+ #ifdef WINDOWS
255278 ASSERT_TRUE (futListen.get ());
279+ #else
280+ ConnectThread.join ();
281+ #endif
282+
256283 ASSERT_FALSE (ConnectedClient.m_pSSL == nullptr );
257284 ASSERT_FALSE (ConnectedClient.m_pCTXSSL == nullptr );
258285 ASSERT_FALSE (ConnectedClient.m_SockFd == INVALID_SOCKET);
0 commit comments