Skip to content

Commit a7a5062

Browse files
committed
add api test for checking domain name
use SNI example.com in client ssl
1 parent 2d892f0 commit a7a5062

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

tests/api.c

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32755,6 +32755,59 @@ static int test_wolfSSL_check_domain(void)
3275532755
}
3275632756

3275732757
#endif /* OPENSSL_EXTRA && HAVE_SSL_MEMIO_TESTS_DEPENDENCIES */
32758+
#if defined(HAVE_SSL_MEMIO_TESTS_DEPENDENCIES) && \
32759+
!defined(WOLFSSL_SYS_CA_CERTS)
32760+
static const char* dn = NULL;
32761+
static int test_wolfSSL_check_domain_basic_client_ctx(WOLFSSL_CTX* ctx)
32762+
{
32763+
EXPECT_DECLS;
32764+
32765+
ExpectIntEQ(wolfSSL_CTX_load_system_CA_certs(ctx), WOLFSSL_SUCCESS);
32766+
wolfSSL_CTX_set_verify(ctx, WOLFSSL_VERIFY_PEER, NULL);
32767+
32768+
return EXPECT_RESULT();
32769+
}
32770+
static int test_wolfSSL_check_domain_basic_client_ssl(WOLFSSL* ssl)
32771+
{
32772+
EXPECT_DECLS;
32773+
32774+
ExpectIntEQ(wolfSSL_check_domain_name(ssl, dn), WOLFSSL_SUCCESS);
32775+
32776+
return EXPECT_RESULT();
32777+
}
32778+
static int test_wolfSSL_check_domain_basic(void)
32779+
{
32780+
EXPECT_DECLS;
32781+
test_ssl_cbf func_cb_client;
32782+
test_ssl_cbf func_cb_server;
32783+
32784+
XMEMSET(&func_cb_client, 0, sizeof(func_cb_client));
32785+
XMEMSET(&func_cb_server, 0, sizeof(func_cb_server));
32786+
32787+
func_cb_client.ctx_ready = &test_wolfSSL_check_domain_basic_client_ctx;
32788+
32789+
dn = "invalid.com";
32790+
func_cb_client.ssl_ready = &test_wolfSSL_check_domain_basic_client_ssl;
32791+
32792+
/* Expect to fail */
32793+
ExpectIntEQ(test_wolfSSL_client_server_nofail_memio(&func_cb_client,
32794+
&func_cb_server, NULL), -1001);
32795+
32796+
dn = "example.com";
32797+
32798+
/* Expect to succeed */
32799+
ExpectIntEQ(test_wolfSSL_client_server_nofail_memio(&func_cb_client,
32800+
&func_cb_server, NULL), TEST_SUCCESS);
32801+
32802+
return EXPECT_RESULT();
32803+
}
32804+
#else
32805+
static int test_wolfSSL_check_domain_basic(void)
32806+
{
32807+
EXPECT_DECLS;
32808+
return EXPECT_RESULT();
32809+
}
32810+
#endif /* HAVE_SSL_MEMIO_TESTS_DEPENDENCIES */
3275832811

3275932812
static int test_wolfSSL_X509_get_X509_PUBKEY(void)
3276032813
{
@@ -67810,6 +67863,7 @@ TEST_CASE testCases[] = {
6781067863
#endif
6781167864

6781267865
TEST_DECL(test_wolfSSL_check_domain),
67866+
TEST_DECL(test_wolfSSL_check_domain_basic),
6781367867
TEST_DECL(test_wolfSSL_cert_cb),
6781467868
TEST_DECL(test_wolfSSL_cert_cb_dyn_ciphers),
6781567869
TEST_DECL(test_wolfSSL_ciphersuite_auth),

0 commit comments

Comments
 (0)