Created
July 19, 2023 14:30
-
-
Save dirkx/636f0ed0efa790806116f2f10bd701bd to your computer and use it in GitHub Desktop.
quick hack to let asterisk deal with wild cards and still verify
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef DO_SSL | |
static int check_tcptls_cert_name(ASN1_STRING *cert_str, const char *hostname, const char *desc) | |
{ | |
unsigned char *str; char *dot; | |
int ret; | |
ret = ASN1_STRING_to_UTF8(&str, cert_str); | |
if (ret < 0 || !str) { | |
return -1; | |
} | |
if (strlen((char *) str) != ret) { | |
ast_log(LOG_WARNING, "Invalid certificate %s length (contains NULL bytes?)\n", desc); | |
ret = -1; | |
} else if (!strcasecmp(hostname, (char *) str)) { | |
ret = 0; | |
// not very safe/comprehensive/tested | |
} else if ((str[0] == '*') && (dot = index(hostname,'.')) && (!strcasecmp(dot, (char *) str+1))) { | |
ast_log(LOG_WARNING, "Matching %s on wildcard %s\n", hostname, str); | |
ret = 0; | |
} else { | |
ret = -1; | |
} | |
ast_debug(3, "SSL %s compare s1='%s' s2='%s'\n", desc, hostname, str); | |
OPENSSL_free(str); | |
return ret; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment