@@ -35,14 +35,25 @@ using namespace datastax::internal::core;
35
35
36
36
namespace {
37
37
38
- static void setenv (const std::string& name, const std::string& value) {
38
+ void setenv (const std::string& name, const std::string& value) {
39
39
#ifdef _WIN32
40
40
_putenv (const_cast <char *>(std::string (name + " =" + value).c_str ()));
41
41
#else
42
42
::setenv (name.c_str(), value.c_str(), 1);
43
43
#endif
44
44
}
45
45
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
+
46
57
}
47
58
48
59
class ConnectionUnitTest : public LoopTest {
@@ -208,7 +219,7 @@ TEST_F(ConnectionUnitTest, Ssl) {
208
219
TEST_F (ConnectionUnitTest, SslDefaultVerifyPaths) {
209
220
const String host = " 127.0.0.1" ;
210
221
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 " ;
212
223
213
224
mockssandra::SimpleCluster cluster (simple ());
214
225
const String cert = cluster.use_ssl (host);
@@ -228,11 +239,14 @@ TEST_F(ConnectionUnitTest, SslDefaultVerifyPaths) {
228
239
EXPECT_EQ (connect_rc, Connector::CONNECTION_ERROR_SSL_VERIFY)
229
240
<< " Verification succeeded without certificate." ;
230
241
242
+ const String cwd = current_dir ();
243
+
231
244
// Generate certificate as file (which is used by our mock cluster) and import it
232
245
std::ofstream cert_buffer (cert_path.c_str ());
233
246
cert_buffer << cert;
234
247
cert_buffer.close ();
235
248
setenv (" SSL_CERT_FILE" , cert_path.c_str ());
249
+ setenv (" SSL_CERT_DIR" , cwd.c_str ());
236
250
std::cout << " Debug SslDefaultVerifyPaths: SSL_CERT_FILE " << cert_path << " " << cert << std::endl;
237
251
for (const auto var: {" SSL_CERT_FILE" , " SSL_CERT_DIR" }) {
238
252
const char * value = std::getenv (var);
0 commit comments