大网数据广告活动
服务器运维问答

Insecure after setting up SSL/HTTPS on my nginx server

· 52CE 我爱测

I'm trying to set up HTTPS/SSL on my site test.example.com . I edited my file at /etc/nginx/sites-enabled/my_site so that the top section of the server {} block is this. server { listen 443; ssl on; ssl_certificate /etc/ssl/cert_…

问题原文

原帖链接 · Username · CC BY-SA 4.0

I'm trying to set up HTTPS/SSL on my site test.example.com.

I edited my file at /etc/nginx/sites-enabled/my_site so that the top section of the server {} block is this.

server {
    listen 443;
    ssl on;
    ssl_certificate /etc/ssl/cert_chain.crt;
    ssl_certificate_key /etc/ssl/example.key;
    server_name test.example.com;
    error_log /var/log/nginx/debug.log debug;

    ... Rest of code ...
}

I ran nginx restart. But if I go to https://test.testexample.com in Chromium, my browser warns that my connection to the site is insecure.

Chromium error:

Your connection is not private
Attackers might be trying to steal your information from test.example.com (for example, passwords, messages, or credit cards). Learn more
NET::ERR_CERT_COMMON_NAME_INVALID

This server could not prove that it is test.example.com; its security certificate is from example.com. This may be caused by a misconfiguration or an attacker intercepting your connection.

My certificate was issued by Comodo. I'm following Namecheap's guide on integrating SSL into my site. Step 3: https://www.namecheap.com/support/knowledgebase/article.aspx/9419/0/nginx

已采纳解答

原帖链接 · Steffen Ullrich · CC BY-SA 4.0

NET::ERR_CERT_COMMON_NAME_INVALID ...
This server could not prove that it is test.example.com; its security certificate is from example.com. This may be caused by a misconfiguration or an attacker intercepting your connection.

The certificate returned by the server does not match the name in the URL. Based on this description you've ordered a certificate for example.com but try to access the site as test.example.com which is not the domain the certificate was issued for.

This problem might be due to a wrong understanding of how the comparison of the domain in the URL against the certificate works. In general:

  • A certificate is only valid for the domains explicitly mentioned in the subject alternative names section of the certificate (Chrome ignores CN). This means example.com does not match test.example.com.
  • If you have a wildcard there can only be one *, it must be the leftmost label and it matches only a single part of the domain, i.e. a certificate for *.example.com will match www.example.com and test.example.com but not www.test.example.com.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-05-12)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。