X-Git-Url: http://www.privoxy.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=ssl.c;h=85701ce03a47fe6b1b88b8d0700fa18b4365e230;hb=43c52225d923808609482b95968c71a963fdf0dc;hp=860a243f96a57cfae253df9cdc1eda29727e566e;hpb=feac1af513ca52a316c3aa60f1bc1a2c63111c13;p=privoxy.git diff --git a/ssl.c b/ssl.c index 860a243f..85701ce0 100644 --- a/ssl.c +++ b/ssl.c @@ -28,6 +28,7 @@ * *********************************************************************/ +#include #include #include @@ -1519,6 +1520,50 @@ exit: } + +/********************************************************************* + * + * Function : host_is_ip_address + * + * Description : Checks whether or not a host is specified by + * IP address. Does not actually validate the + * address. + * + * Parameters : + * 1 : host = The host name to check + * + * Returns : 1 => Yes + * 0 => No + * + *********************************************************************/ +static int host_is_ip_address(const char *host) +{ + const char *p; + + if (NULL != strstr(host, ":")) + { + /* Assume an IPv6 address. */ + return 1; + } + + for (p = host; *p; p++) + { + if ((*p != '.') && !privoxy_isdigit(*p)) + { + /* Not a dot or digit so it can't be an IPv4 address. */ + return 0; + } + } + + /* + * Host only consists of dots and digits so + * assume that is an IPv4 address. + */ + return 1; + +} + + /********************************************************************* * * Function : generate_webpage_certificate @@ -1894,7 +1939,8 @@ static int generate_webpage_certificate(struct client_state *csp) } #endif /* MBEDTLS_SHA1_C */ - if (set_subject_alternative_name(&cert, csp->http->host)) + if (!host_is_ip_address(csp->http->host) && + set_subject_alternative_name(&cert, csp->http->host)) { /* Errors are already logged by set_subject_alternative_name() */ ret = -1;