Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/ts/test_X509HostnameValidator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ REGRESSION_TEST(CN_match)(RegressionTest *t, int /* atype ATS_UNUSED */, int *ps
box.check(validate_hostname(x, (unsigned char *)test_certificate_cn_name, false, &matching) == true, "Hostname should match");
box.check(strcmp(test_certificate_cn_name, matching) == 0, "Return hostname doesn't match lookup");
box.check(validate_hostname(x, (unsigned char *)test_certificate_cn_name + 1, false, NULL) == false, "Hostname shouldn't match");
ats_free(matching);
}

REGRESSION_TEST(bad_wildcard_SANs)(RegressionTest *t, int /* atype ATS_UNUSED */, int *pstatus)
Expand All @@ -130,11 +131,13 @@ REGRESSION_TEST(wildcard_SAN_and_CN)(RegressionTest *t, int /* atype ATS_UNUSED
box.check(x != NULL, "failed to load the test certificate");
box.check(validate_hostname(x, (unsigned char *)test_certificate_cn_name, false, &matching) == true, "Hostname should match");
box.check(strcmp(test_certificate_cn_name, matching) == 0, "Return hostname doesn't match lookup");
ats_free(matching);

box.check(validate_hostname(x, (unsigned char *)"a.trafficserver.org", false, &matching) == true, "Hostname should match");
box.check(strcmp("*.trafficserver.org", matching) == 0, "Return hostname doesn't match lookup");

box.check(validate_hostname(x, (unsigned char *)"a.*.trafficserver.org", false, NULL) == false, "Hostname shouldn't match");
ats_free(matching);
}

REGRESSION_TEST(IDNA_hostnames)(RegressionTest *t, int /* atype ATS_UNUSED */, int *pstatus)
Expand All @@ -147,6 +150,7 @@ REGRESSION_TEST(IDNA_hostnames)(RegressionTest *t, int /* atype ATS_UNUSED */, i
box.check(validate_hostname(x, (unsigned char *)"xn--foobar.trafficserver.org", false, &matching) == true,
"Hostname should match");
box.check(strcmp("*.trafficserver.org", matching) == 0, "Return hostname doesn't match lookup");
ats_free(matching);

// IDNA means wildcard must match full label
box.check(validate_hostname(x, (unsigned char *)"xn--foobar.trafficserver.net", false, &matching) == false,
Expand All @@ -163,9 +167,11 @@ REGRESSION_TEST(middle_label_match)(RegressionTest *t, int /* atype ATS_UNUSED *
box.check(validate_hostname(x, (unsigned char *)"foosomething.trafficserver.com", false, &matching) == true,
"Hostname should match");
box.check(strcmp("foo*.trafficserver.com", matching) == 0, "Return hostname doesn't match lookup");
ats_free(matching);
box.check(validate_hostname(x, (unsigned char *)"somethingbar.trafficserver.net", false, &matching) == true,
"Hostname should match");
box.check(strcmp("*bar.trafficserver.net", matching) == 0, "Return hostname doesn't match lookup");
ats_free(matching);

box.check(validate_hostname(x, (unsigned char *)"a.bar.trafficserver.net", false, NULL) == false, "Hostname shouldn't match");
box.check(validate_hostname(x, (unsigned char *)"foo.bar.trafficserver.net", false, NULL) == false, "Hostname shouldn't match");
Expand Down