使用虚拟主机(apache + xampp)时出现 SSL 错误

使用虚拟主机(apache + xampp)时出现 SSL 错误

我的 Windows Server 2003 vps 上有多个网站,通过 xampp 运行 apache2。我正在使用 openssl。

当我仅在 1 个站点(我有 2 个活动站点)上启用 SSL 时,一切都运行正常 - 但现在我遇到了问题。

我无法访问https://liamwli.co.uk(或非安全变体),因为当我尝试访问它时,谷歌浏览器会出现错误:

SSL 连接错误 无法与服务器建立安全连接。这可能是服务器的问题,或者它可能需要您没有的客户端身份验证证书。错误 107 (net::ERR_SSL_PROTOCOL_ERROR):SSL 协议错误。

我可以访问我的其他网站 (techmastersforum.co.uk),但它提供的网站非常简陋。当我尝试通过 https 访问 techmastersforum.co.uk 时,它给出了证书错误,因为它试图使用我的其他域名的证书。

我的 httpd-vhosts.conf 文件的内容是:

NameVirtualHost *:80
    <VirtualHost *:80>
        ServerAdmin [email protected]
        DocumentRoot "C:/xampp/xampp/htdocs"
        ServerName techmastersforum.co.uk
        ServerAlias www.techmastersforum.co.uk
        ErrorLog "logs/dummy-host.localhost-error.log"
        CustomLog "logs/dummy-host.localhost-access.log" combined
    </VirtualHost>
    <VirtualHost *:443>
        ServerAdmin [email protected]
        DocumentRoot "C:\xampp\xampp\blog"
        ServerName liamwli.co.uk
        ServerAlias www.liamwli.co.uk
        ErrorLog "logs/liamwlissl.log"
        CustomLog "logs/liamwlissl.log" combined
        SSLEngine On
        SSLCertificateFile "C:\xampp\xampp\certs\www_liamwli_co_uk.crt"
        SSLCertificateKeyFile "C:\xampp\xampp\certs\www_liamwli_co_uk.key"
        SSLCACertificateFile "C:\xampp\xampp\certs\GeoTrust_CA_Bundle.crt"
    </VirtualHost>

    <VirtualHost *:443>
        ServerAdmin [email protected]
        DocumentRoot "C:\xampp\xampp\htdocs"
        ServerName techmastersforum.co.uk
        ServerAlias www.techmastersforum.co.uk
        ErrorLog "logs/tmfssl.log"
        CustomLog "logs/tmfssl.log" combined
        SSLEngine On
        SSLCertificateFile "C:\xampp\xampp\certs\www_techmastersforum_co_uk.crt"
        SSLCertificateKeyFile "C:\xampp\xampp\certs\www_techmastersforum_co_uk.key"
        SSLCACertificateFile "C:\xampp\xampp\certs\GeoTrust_CA_Bundle.crt"
    </VirtualHost>

    <VirtualHost *:80>
        ServerAdmin [email protected]
        DocumentRoot "C:\xampp\xampp\blog"
        ServerName liamwli.co.uk
        ServerAlias www.liamwli.co.uk
        ErrorLog "logs/dummy-host.localhost-error.log"
        CustomLog "logs/dummy-host.localhost-access.log" combined
    </VirtualHost>

有人知道我遇到了什么问题吗?

正如我所说,我在 Windows Server 2003 VPS 上通过 XAMPP 运行 Apache2。

答案1

正如这个答案所解释的那样,您不能对同一个端点 (ipaddress:port) 使用 2 个不同的证书。

如果您有 2 个静态 IP 地址,请为每个地址分配一个 HTTPS 虚拟主机,如下所示:

<VirtualHost 1.1.1.1:443>
    ServerAdmin [email protected]
    DocumentRoot "C:\xampp\xampp\blog"
    ServerName liamwli.co.uk
    ServerAlias www.liamwli.co.uk
    ErrorLog "logs/liamwlissl.log"
    CustomLog "logs/liamwlissl.log" combined
    SSLEngine On
    SSLCertificateFile "C:\xampp\xampp\certs\www_liamwli_co_uk.crt"
    SSLCertificateKeyFile "C:\xampp\xampp\certs\www_liamwli_co_uk.key"
    SSLCACertificateFile "C:\xampp\xampp\certs\GeoTrust_CA_Bundle.crt"
</VirtualHost>

<VirtualHost 2.2.2.2:443>
    ServerAdmin [email protected]
    DocumentRoot "C:\xampp\xampp\htdocs"
    ServerName techmastersforum.co.uk
    ServerAlias www.techmastersforum.co.uk
    ErrorLog "logs/tmfssl.log"
    CustomLog "logs/tmfssl.log" combined
    SSLEngine On
    SSLCertificateFile "C:\xampp\xampp\certs\www_techmastersforum_co_uk.crt"
    SSLCertificateKeyFile "C:\xampp\xampp\certs\www_techmastersforum_co_uk.key"
    SSLCACertificateFile "C:\xampp\xampp\certs\GeoTrust_CA_Bundle.crt"
</VirtualHost>

答案2

我遇到了这个问题。不过我设法解决了它。我建议您使用 httpd.exe -t 选项来检查语法错误。

您应该在 ssl 插入上方提供 NameVirtualHost *:443 指令。我已提供修复的 httpd-vhosts.conf 文件。

NameVirtualHost *:80
    <VirtualHost *:80>
        ServerAdmin [email protected]
        DocumentRoot "C:/xampp/xampp/htdocs"
        ServerName techmastersforum.co.uk
        ServerAlias www.techmastersforum.co.uk
        ErrorLog "logs/dummy-host.localhost-error.log"
        CustomLog "logs/dummy-host.localhost-access.log" combined
    </VirtualHost>

    <VirtualHost *:80>
        ServerAdmin [email protected]
        DocumentRoot "C:\xampp\xampp\blog"
        ServerName liamwli.co.uk
        ServerAlias www.liamwli.co.uk
        ErrorLog "logs/dummy-host.localhost-error.log"
        CustomLog "logs/dummy-host.localhost-access.log" combined
    </VirtualHost>

NameVirtualHost *:443

<VirtualHost *:443>
        ServerAdmin [email protected]
        DocumentRoot "C:\xampp\xampp\blog"
        ServerName liamwli.co.uk
        ServerAlias www.liamwli.co.uk
        ErrorLog "logs/liamwlissl.log"
        CustomLog "logs/liamwlissl.log" combined
        SSLEngine On
        SSLCertificateFile "C:\xampp\xampp\certs\www_liamwli_co_uk.crt"
        SSLCertificateKeyFile "C:\xampp\xampp\certs\www_liamwli_co_uk.key"
        SSLCACertificateFile "C:\xampp\xampp\certs\GeoTrust_CA_Bundle.crt"
    </VirtualHost>

    <VirtualHost *:443>
        ServerAdmin [email protected]
        DocumentRoot "C:\xampp\xampp\htdocs"
        ServerName techmastersforum.co.uk
        ServerAlias www.techmastersforum.co.uk
        ErrorLog "logs/tmfssl.log"
        CustomLog "logs/tmfssl.log" combined
        SSLEngine On
        SSLCertificateFile "C:\xampp\xampp\certs\www_techmastersforum_co_uk.crt"
        SSLCertificateKeyFile "C:\xampp\xampp\certs\www_techmastersforum_co_uk.key"
        SSLCACertificateFile "C:\xampp\xampp\certs\GeoTrust_CA_Bundle.crt"
    </VirtualHost>

相关内容