upstream SSL certificate does not match "x.x.x.x"

Francis Daly francis at
Wed Oct 28 13:04:02 UTC 2020

On Wed, Oct 28, 2020 at 12:28:04AM -0400, bouvierh wrote:

Hi there,

it looks to me like you've come across a case that the current nginx
code does not handle in the way that you want it to.

Maybe the nginx code could be changed to handle this case; or maybe it
will be decided that what nginx does is correct.

Either way -- until a code change is made on the nginx side, you will
have to either use something other than nginx, or change something on
your side to work within the current nginx implementation.

>         location / {
>             proxy_http_version 1.1;
>             resolver;
>             proxy_ssl_trusted_certificate trustedCA.crt;
>             proxy_ssl_verify_depth 7;
>             proxy_ssl_verify       on;
>             proxy_pass;
>         }

> However when I try to curl my "NGINX_SERVER":
> curl https://"NGINX_SERVER
> I get:
>  *110 upstream SSL certificate does not match "" while SSL
> handshaking to upstream, client:, server: , request: 
> Looking at the server certificate, everything looks ok:
>         Subject: CN =
>             X509v3 Subject Alternative Name:
>                 IP Address:, DNS:iotedgeapiproxy
> I am at loss. How can curl/openssl tell me my server cert is valid while
> nginx telling me it is wrong. What am I doing wrong?

What nginx currently does (at least: looking at the 1.17.2 code, which
I happen to have to hand), is:

* if there is a Subject Alternative Name defined, then it is looked at
and Subject is ignored.
* within Subject Alternative Name, only DNS values are looked at (not
IP Address values).

And your certificate happens to mean that nginx-as-implemented-today
will not accept it as valid for the IP address.

Possibly adding

  proxy_ssl_name iotedgeapiproxy;

to your config will make things Just Work.

Alternatively, changing the proxy_pass to refer to
https://iotedgeapiproxy, and making sure that that resolves to the IP
address (by using an "upstream" definition, or by having your system
resolver respond appropriately at nginx startup) should work, but that
might have consequences for returned Location: headers and the like.

The other options would involve not verifying the certificate (bad!),
or re-issuing the certificate either with no Subject Alternative Name,
or with an extra value in the "DNS" part of the Subject Alternative Name
that is the IP address, just to work around the nginx implementation.

Hopefully the "proxy_ssl_name" addition will be enough.

Good luck with it,

Francis Daly        francis at

More information about the nginx mailing list