Skip to content

Commit c133d3d

Browse files
committed
Use absolute path for SSL_CERT_FILE
1 parent b5ce7e3 commit c133d3d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

tests/src/unit/tests/test_connection.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ TEST_F(ConnectionUnitTest, Ssl) {
196196
TEST_F(ConnectionUnitTest, SslDefaultVerifyPaths) {
197197
const String host = "127.0.0.1";
198198
const int verification_flags = CASS_SSL_VERIFY_PEER_CERT | CASS_SSL_VERIFY_PEER_IDENTITY;
199-
const char* cert_path = "cassandra-unit-test.cert";
199+
const String cert_path = std::tmpnam(nullptr);
200200

201201
mockssandra::SimpleCluster cluster(simple());
202202
const String cert = cluster.use_ssl(host);
@@ -217,13 +217,14 @@ TEST_F(ConnectionUnitTest, SslDefaultVerifyPaths) {
217217
<< "Verification succeeded without certificate.";
218218

219219
// Generate certificate as file (which is used by our mock cluster) and import it
220-
std::ofstream cert_buffer(cert_path);
220+
std::ofstream cert_buffer(cert_path.c_str());
221221
cert_buffer << cert;
222222
cert_buffer.close();
223-
ASSERT_EQ(uv_os_setenv("SSL_CERT_FILE", cert_path), 0) << "Failed to prepare openssl environment";
223+
ASSERT_EQ(uv_os_setenv("SSL_CERT_FILE", cert_path.c_str()), 0)
224+
<< "Failed to prepare openssl environment";
224225
ASSERT_EQ(settings.socket_settings.ssl_context->set_default_verify_paths(), CASS_OK)
225226
<< "Failed to import default / system SSL certificates.";
226-
ASSERT_EQ(std::remove(cert_path), 0) << "Failed to cleanup temporary certificate file.";
227+
ASSERT_EQ(std::remove(cert_path.c_str()), 0) << "Failed to cleanup temporary certificate file.";
227228

228229
// Ensure verification succeeds with this certificate.
229230
State state;

0 commit comments

Comments
 (0)