static void
test_mongoc_tls_no_certs (void)
{
   mongoc_ssl_opt_t sopt = { 0 };
   mongoc_ssl_opt_t copt = { 0 };
   ssl_test_result_t sr;
   ssl_test_result_t cr;

   ssl_test (&copt, &sopt, "doesnt_matter", &cr, &sr);

   ASSERT (cr.result == SSL_TEST_SSL_HANDSHAKE);
   ASSERT (sr.result == SSL_TEST_SSL_HANDSHAKE);
}
static void
test_mongoc_tls_bad_verify (void)
{
   mongoc_ssl_opt_t sopt = { 0 };
   mongoc_ssl_opt_t copt = { 0 };
   ssl_test_result_t sr;
   ssl_test_result_t cr;

   sopt.pem_file = PEMFILE_NOPASS;
   sopt.ca_file = CAFILE;

   copt.ca_file = CAFILE;

   ssl_test (&copt, &sopt, "bad_domain.com", &cr, &sr);

   ASSERT (cr.result == SSL_TEST_SSL_VERIFY);
   ASSERT (sr.result == SSL_TEST_TIMEOUT);
}
static void
test_mongoc_tls_trust_dir (void)
{
   mongoc_ssl_opt_t sopt = { 0 };
   mongoc_ssl_opt_t copt = { 0 };
   ssl_test_result_t sr;
   ssl_test_result_t cr;

   sopt.pem_file = PEMFILE_NOPASS;
   sopt.ca_dir = VERIFY_DIR;

   copt.ca_dir = VERIFY_DIR;

   ssl_test (&copt, &sopt, HOST, &cr, &sr);

   ASSERT (cr.result == SSL_TEST_SUCCESS);
   ASSERT (sr.result == SSL_TEST_SUCCESS);
}
static void
test_mongoc_tls_ip (void)
{
   mongoc_ssl_opt_t sopt = { 0 };
   mongoc_ssl_opt_t copt = { 0 };
   ssl_test_result_t sr;
   ssl_test_result_t cr;

   sopt.pem_file = PEMFILE_ALT;
   sopt.ca_file = CAFILE;

   copt.ca_file = CAFILE;

   ssl_test (&copt, &sopt, "10.0.0.1", &cr, &sr);

   ASSERT (cr.result == SSL_TEST_SUCCESS);
   ASSERT (sr.result == SSL_TEST_SUCCESS);
}
static void
test_mongoc_tls_basic (void)
{
   mongoc_ssl_opt_t sopt = { 0 };
   mongoc_ssl_opt_t copt = { 0 };
   ssl_test_result_t sr;
   ssl_test_result_t cr;

   sopt.pem_file = PEMFILE_NOPASS;
   sopt.ca_file = CAFILE;

   copt.ca_file = CAFILE;

   ssl_test (&copt, &sopt, HOST, &cr, &sr);

   ASSERT (cr.result == SSL_TEST_SUCCESS);
   ASSERT (sr.result == SSL_TEST_SUCCESS);
}
static void
test_mongoc_tls_bad_password (void)
{
   mongoc_ssl_opt_t sopt = { 0 };
   mongoc_ssl_opt_t copt = { 0 };
   ssl_test_result_t sr;
   ssl_test_result_t cr;

   sopt.pem_file = PEMFILE_PASS;
   sopt.ca_file = CAFILE;
   sopt.pem_pwd = "badpass";

   copt.ca_file = CAFILE;

   ssl_test (&copt, &sopt, "pass.mongodb.com", &cr, &sr);

   ASSERT (cr.result == SSL_TEST_SSL_HANDSHAKE);
   ASSERT (sr.result == SSL_TEST_SSL_INIT);
}
static void
test_mongoc_tls_wild (void)
{
   mongoc_ssl_opt_t sopt = { 0 };
   mongoc_ssl_opt_t copt = { 0 };
   ssl_test_result_t sr;
   ssl_test_result_t cr;

   sopt.pem_file = PEMFILE_ALT;
   sopt.ca_file = CAFILE;
   sopt.weak_cert_validation = true;

   copt.ca_file = CAFILE;

   ssl_test (&copt, &sopt, "unicorn.wild.mongodb.com", &cr, &sr);

   ASSERT (cr.result == SSL_TEST_SUCCESS);
   ASSERT (sr.result == SSL_TEST_SUCCESS);
}
static void
test_mongoc_tls_crl (void)
{
   mongoc_ssl_opt_t sopt = { 0 };
   mongoc_ssl_opt_t copt = { 0 };
   ssl_test_result_t sr;
   ssl_test_result_t cr;

   sopt.pem_file = PEMFILE_REV;
   sopt.ca_file = CAFILE;

   copt.ca_file = CAFILE;
   copt.crl_file = CRLFILE;

   ssl_test (&copt, &sopt, "rev.mongodb.com", &cr, &sr);

   ASSERT (cr.result == SSL_TEST_SSL_HANDSHAKE);
   ASSERT (sr.result == SSL_TEST_SSL_HANDSHAKE);
}
static void
test_mongoc_tls_no_verify (void)
{
   mongoc_ssl_opt_t sopt = { 0 };
   mongoc_ssl_opt_t copt = { 0 };
   ssl_test_result_t sr;
   ssl_test_result_t cr;

   sopt.pem_file = PEMFILE_NOPASS;
   sopt.ca_file = CAFILE;

   copt.ca_file = CAFILE;
   copt.weak_cert_validation = 1;

   ssl_test (&copt, &sopt, "bad_domain.com", &cr, &sr);

   ASSERT (cr.result == SSL_TEST_SUCCESS);
   ASSERT (sr.result == SSL_TEST_SUCCESS);
}
Exemple #10
0
static void
test_mongoc_tls_password (void)
{
   mongoc_ssl_opt_t sopt = { 0 };
   mongoc_ssl_opt_t copt = { 0 };
   ssl_test_result_t sr;
   ssl_test_result_t cr;

   sopt.pem_file = PEMFILE_PASS;
   sopt.ca_file = CAFILE;
   sopt.pem_pwd = PASSWORD;

   copt.ca_file = CAFILE;

   ssl_test (&copt, &sopt, "pass.mongodb.com", &cr, &sr);

   ASSERT (cr.result == SSL_TEST_SUCCESS);
   ASSERT (sr.result == SSL_TEST_SUCCESS);
}