in tls/s2n_connection.c [215:245]
static uint8_t s2n_default_verify_host(const char *host_name, size_t len, void *data)
{
/* if present, match server_name of the connection using rules
* outlined in RFC6125 6.4. */
struct s2n_connection *conn = data;
if (conn->server_name[0] == '\0') {
return 0;
}
/* complete match */
if (strlen(conn->server_name) == len && strncasecmp(conn->server_name, host_name, len) == 0) {
return 1;
}
/* match 1 level of wildcard */
if (len > 2 && host_name[0] == '*' && host_name[1] == '.') {
const char *suffix = strchr(conn->server_name, '.');
if (suffix == NULL) {
return 0;
}
if (strlen(suffix) == len - 1 && strncasecmp(suffix, host_name + 1, len - 1) == 0) {
return 1;
}
}
return 0;
}