【问题标题】:Issue with HTTPS requests only to www subdomain仅对 www 子域的 HTTPS 请求问题
【发布时间】:2016-09-29 10:09:29
【问题描述】:

我将 Apache 配置为服务 HTTPS 请求并将所有 HTTP 请求重定向到 HTTPS。但是……

对于https://www.example.com,Web 浏览器只是挂起,而 Apache 在日志中什么也没有显示,没有错误,也没有访问。我什至不确定这是一个 Apache 问题,我有点迷茫。有什么提示吗?

我的 SSL 证书有 CN example.com,我的 Apache 配置文件是:

<VirtualHost *:80>
        ServerName example.com
        ServerAlias www.example.com
        DocumentRoot ...
        Redirect permanent / https://example.com/
</VirtualHost>

<VirtualHost _default_:443>
        ServerName example.com
        ServerAlias www.example.com

        DocumentRoot ...    
        SSLEngine on
        ...    
</VirtualHost>

【问题讨论】:

  • 如果您的 SSL 证书链中没有 www. 域,则 vhost 配置将无效。
  • 奇怪的是,我的 CA Gandi 声明 “www 子域是由 CA 自动添加的,例如,example.com 将保护 example.com 和 www.example.com”
  • 只有当您的证书是通配符时才会发生这种情况。通配符证书将保护您设置的任何子域。
  • @alejdg Gandi's doc says: 如果您有单地址证书要激活,如果您使用裸域(例如 example.com)创建 CSR,则会自动添加 www 子域例如,通过 CA,example.com 将保护 example.com 和 www.example.com。反之亦然,如果您使用 www 子域创建 CSR,裸域也将是安全的。

标签: apache ssl https


【解决方案1】:

Gandi's doc says: 如果你有一个单地址证书要激活,如果你用裸域(例如example.com)创建CSR,那么www子域是由CA自动添加的,例如, example.com 将保护 example.com 和 www.example.com。反之亦然,如果您使用 www 子域创建 CSR,裸域也将是安全的。

我只是碰巧生成了一个以www.example.com 作为通用名称的文件,但是无论文档说什么都是自动的,我确保在我用来生成 CSR 的 OpenSSL 的 .cnf 中包含 alt 名称:

[ req ]
default_md = sha256
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid:always,issuer
prompt = no
string_mask = utf8only
distinguished_name = host_distinguished_name
req_extensions = host_extensions

[ host_distinguished_name ]
commonName = www.example.com
stateOrProvinceName = Somewhere
countryName = US
emailAddress = root@example.com
organizationName = ACME

[ host_extensions ]
subjectAltName = @alt-names
basicConstraints = CA:false

[ alt-names ]
DNS.1 = www.example.com
DNS.2 = example.com

在某些 Debian 上生成了私钥和 CSR:

$ subject=www.example.com
$ openssl genrsa -out ${subject}.key 2048
$ openssl req -config ${subject}.cnf -new -key ${subject}.key -out ${subject}.csr

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-02-25
    • 1970-01-01
    • 1970-01-01
    • 2014-07-29
    • 2012-02-20
    • 2015-04-26
    • 2014-01-20
    相关资源
    最近更新 更多