A client accessing an HTTPS website need to verify two things about its certificate:
- They must check that the certificate is genuine, issued by a trusted authority (and valid for this purpose). This is the PKI model, specified in RFC 5280.
- They must check that the certificate was issued to the entity they are trying to contact. This is the host name verification, specified in RFC 2818 Section 3.1 (and later in RFC 6125).
The PKI verification is addressed by configuring the client set a trust anchors (trusted CA certificates). If your certificate was issued by a CA trusted by default by your OS, you shouldn't need to do anything. If you had to install the CA certificate yourself, make sure it's also enabled in the machine's store (not just the user's store), since your application may be running as a service (and not under a specific user).
The identity verification relies on the identity you're trying to contact (host name or IP address) and the identity to which the certificate has been issued. They must match. The rules are in RFC 2818 Section 3.1, in particular:
If a subjectAltName extension of type dNSName is present, that MUST
be used as the identity. Otherwise, the (most specific) Common Name
field in the Subject field of the certificate MUST be used. Although
the use of the Common Name is existing practice, it is deprecated and
Certification Authorities are encouraged to use the dNSName instead.
[...]
In some cases, the URI is specified as an IP address rather than a
hostname. In this case, the iPAddress subjectAltName must be present
in the certificate and must exactly match the IP in the URI.
Your server may be responding internally to multiple host names and IP addresses, for example www.example.com
, 192.168.1.100
, localhost
, 127.0.0.1
. Your certificate must be valid for the host/IP address you're trying to contact it with.
It rarely makes sense to have a certificate issued to localhost
or 127.0.0.1
, so I doubt that's what you have, and there's no point configuring your client with https://localhost/...
for this reason.
It's possible to have a certificate for 192.168.1.100
, but it MUST have an IP (not DNS) Subject Alternative Name entry for this IP address. (Considering it's a private address, it's quite unlikely to be the case.)
It's possible that you need to configure your service to use the visible host name (the one for which your certificate was probably issued): www.example.com
(or whatever it is). There might be problems if you're hosting this service behind a reverse NAT.