Nginx NET::ERR_CERT_COMMON_NAME_INVALID

Nginx NET::ERR_CERT_COMMON_NAME_INVALID

我正在尝试为部署在 DigitalOcean 上的 Web 应用程序启用 ssl 证书,但是当我访问 Droplet ip 时出现此错误:

NET::ERR_CERT_COMMON_NAME_INVALID
This server could not prove that it is droplet-ip-address; its security certificate is from *.domain.com. This may be caused by a misconfiguration or an attacker intercepting your connection.

这是我的 nginx 配置:

server {
        # SSL configuration
        #
        listen 443 ssl;
        server_name sub.domain.com;
        ssl_certificate /etc/nginx/ssl/star-op/__company_com.ca-chain.cert.pem
        ssl_certificate_key /etc/nginx/ssl/star-op/__company_com.key;
}

目前我没有来自 sub.domain.com 的任何指向我的 IP 地址的 DNS 记录...这可能是该错误的原因吗?

如果没有 DNS 条目,您正在做类似 https://x.x.x.x 的事情,其中​​ nginx 最有可能与 https://sub.domain.com 相关联,因为它是 nginx 中唯一的服务器块时间。

但是 https://x.x.x.xhttps://sub.domain.com 的证书不匹配,因此您的证书不匹配。如果您只是在测试,您可以添加一个 host 文件条目进行测试,这应该能让您解决这个问题。之后,您需要向您的 public DNS 服务器添加一个 DNS 条目,以便世界其他地区不会出现此问题。