Skip to content

Commit

Permalink
Merge 5c711cf into a3f3853
Browse files Browse the repository at this point in the history
  • Loading branch information
smuehlst committed Apr 20, 2018
2 parents a3f3853 + 5c711cf commit 02ba2df
Showing 1 changed file with 43 additions and 4 deletions.
47 changes: 43 additions & 4 deletions lib/vtls/openssl.c
Expand Up @@ -1323,6 +1323,48 @@ static void Curl_ossl_close_all(struct Curl_easy *data)

/* ====================================================== */

/*
* Match subjectAltName against the host name. This requires a conversion
* in CURL_DOES_CONVERSIONS builds.
*/
static int subj_alt_hostcheck(struct Curl_easy *data,
const char *match_pattern, const char *hostname,
const char *dispname)
{
int res = 0;

#ifdef CURL_DOES_CONVERSIONS
/* Curl_cert_hostcheck uses host encoding, but we get ASCII from
OpenSSl.
*/
char *match_pattern2 = strdup(match_pattern);

if(match_pattern2) {
if(Curl_convert_from_network(data, match_pattern2,
strlen(match_pattern2)) == CURLE_OK) {
if(Curl_cert_hostcheck(match_pattern2, hostname)) {
res = 1;
infof(data,
" subjectAltName: host \"%s\" matched cert's \"%s\"\n",
dispname, match_pattern2);
}
}
free(match_pattern2);
}
else {
failf(data,
"SSL: out of memory when allocating temporary for subjectAltName");
}
#else
if(Curl_cert_hostcheck(match_pattern, hostname)) {
res = 1;
infof(data, " subjectAltName: host \"%s\" matched cert's \"%s\"\n",
dispname, match_pattern);
}
#endif

return res;
}

/* Quote from RFC2818 section 3.1 "Server Identity"
Expand Down Expand Up @@ -1422,11 +1464,8 @@ static CURLcode verifyhost(struct connectdata *conn, X509 *server_cert)
if((altlen == strlen(altptr)) &&
/* if this isn't true, there was an embedded zero in the name
string and we cannot match it. */
Curl_cert_hostcheck(altptr, hostname)) {
subj_alt_hostcheck(data, altptr, hostname, dispname)) {
dnsmatched = TRUE;
infof(data,
" subjectAltName: host \"%s\" matched cert's \"%s\"\n",
dispname, altptr);
}
break;

Expand Down

0 comments on commit 02ba2df

Please sign in to comment.