@@ -35,14 +35,25 @@ using namespace datastax::internal::core;
3535
3636namespace {
3737
38- static void setenv (const std::string& name, const std::string& value) {
38+ void setenv (const std::string& name, const std::string& value) {
3939#ifdef _WIN32
4040 _putenv (const_cast <char *>(std::string (name + " =" + value).c_str ()));
4141#else
4242 ::setenv (name.c_str(), value.c_str(), 1);
4343#endif
4444}
4545
46+ String current_dir ()
47+ {
48+ char buffer[256 ];
49+ #ifdef _WIN32
50+ _getcwd (buffer, 256 );
51+ #else
52+ getcwd (buffer, 256 );
53+ #endif
54+ return buffer;
55+ }
56+
4657}
4758
4859class ConnectionUnitTest : public LoopTest {
@@ -208,7 +219,7 @@ TEST_F(ConnectionUnitTest, Ssl) {
208219TEST_F (ConnectionUnitTest, SslDefaultVerifyPaths) {
209220 const String host = " 127.0.0.1" ;
210221 const int verification_flags = CASS_SSL_VERIFY_PEER_CERT | CASS_SSL_VERIFY_PEER_IDENTITY;
211- const String cert_path = std::tmpnam ( nullptr ) ;
222+ const String cert_path = " tmp.cassandra.unit-test.cert " ;
212223
213224 mockssandra::SimpleCluster cluster (simple ());
214225 const String cert = cluster.use_ssl (host);
@@ -228,11 +239,14 @@ TEST_F(ConnectionUnitTest, SslDefaultVerifyPaths) {
228239 EXPECT_EQ (connect_rc, Connector::CONNECTION_ERROR_SSL_VERIFY)
229240 << " Verification succeeded without certificate." ;
230241
242+ const String cwd = current_dir ();
243+
231244 // Generate certificate as file (which is used by our mock cluster) and import it
232245 std::ofstream cert_buffer (cert_path.c_str ());
233246 cert_buffer << cert;
234247 cert_buffer.close ();
235248 setenv (" SSL_CERT_FILE" , cert_path.c_str ());
249+ setenv (" SSL_CERT_DIR" , cwd.c_str ());
236250 std::cout << " Debug SslDefaultVerifyPaths: SSL_CERT_FILE " << cert_path << " " << cert << std::endl;
237251 for (const auto var: {" SSL_CERT_FILE" , " SSL_CERT_DIR" }) {
238252 const char * value = std::getenv (var);
0 commit comments