启用https到Xampp localhost

时间:2018-10-27 12:24:26

标签: apache ssl https xampp localhost

我试图在本地设备上启用https到本地主机,我进行了搜索,但是没有任何效果。

我确保已启用这些功能

httpd.conf中:

LoadModule ssl_module modules/mod_ssl.so

php.ini中:

extension=php_openssl.dll

我将此添加到了httpd-vhosts.conf

<VirtualHost _default_:443> 
    DocumentRoot "C:/xampp/htdocs" 
    ServerName localhost:443 
    ServerAlias localhost:443  
    SSLEngine on 
    SSLCertificateFile "/conf/ssl.crt/server.crt"
    SSLCertificateKeyFile "/conf/ssl.key/server.key"
</VirtualHost> 

我也尝试过:

SSLCertificateFile "C:/xampp/apache/conf/ssl.crt/server.crt"
SSLCertificateKeyFile "C:/xampp/apache/conf/ssl.key/server.key"

但是我得到了

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

Subject: localhost

Issuer: localhost

Expires on: Nov 9, 2019

Current date: Oct 27, 2018

PEM encoded chain:
-----BEGIN CERTIFICATE-----
MIIBnzCCAQgCCQC1x1LJh4G1AzANBgkqhkiG9w0BAQUFADAUMRIwEAYDVQQDEwls
b2NhbGhvc3QwHhcNMDkxMTEwMjM0ODQ3WhcNMTkxMTA4MjM0ODQ3WjAUMRIwEAYD
VQQDEwlsb2NhbGhvc3QwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMEl0yfj
7K0Ng2pt51+adRAj4pCdoGOVjx1BmljVnGOMW3OGkHnMw9ajibh1vB6UfHxu463o
J1wLxgxq+Q8y/rPEehAjBCspKNSq+bMvZhD4p8HNYMRrKFfjZzv3ns1IItw46kgT
gDpAl1cMRzVGPXFimu5TnWMOZ3ooyaQ0/xntAgMBAAEwDQYJKoZIhvcNAQEFBQAD
gYEAavHzSWz5umhfb/MnBMa5DL2VNzS+9whmmpsDGEG+uR0kM1W2GQIdVHHJTyFd
aHXzgVJBQcWTwhp84nvHSiQTDBSaT6cQNQpvag/TaED/SEQpm0VqDFwpfFYuufBL
vVNbLkKxbK2XwUvu0RxoLdBMC/89HqrZ0ppiONuQ+X2MtxE=
-----END CERTIFICATE-----



This server could not prove that it is localhost;
its security certificate is not trusted by your computer's operating system.
This may be caused by a misconfiguration or an attacker intercepting your connection.

443中更改对httpd.conf的监听

listen中的httpd.conf编辑为443后,运行apache时出现错误:

 Diese Eingabeforderung nicht waehrend des Running beenden
Bitte erst bei einem gewollten Shutdown schliessen
Please close this command only for Shutdown
Apache 2 is starting ...
(OS 10048)Only one usage of each socket address (protocol/network address/port)
is normally permitted.  : AH00072: make_sock: could not bind to address [::]:443

(OS 10048)Only one usage of each socket address (protocol/network address/port)
is normally permitted.  : AH00072: make_sock: could not bind to address 0.0.0.0:
443
AH00451: no listening sockets available, shutting down
AH00015: Unable to open logs

Apache konnte nicht gestartet werden
Apache could not be started
Press any key to continue . . .

怎么了?

1 个答案:

答案 0 :(得分:1)

首先,您不必编辑文件Listen中的httpd.conf语句。您可以并且应该这样保留它:

Listen 80

其余配置看起来不错,并且工作正常。出现该错误消息的原因或原因是因为您使用的是自签名证书。该自签名证书没有有效的授权机构(可以验证您证书的公司)。

对于在本地系统上进行测试,这是绝对有效的。但是,如果您想强制浏览器(我从发布的消息中可以看到您正在使用Google Chrome)信任证书,则必须将自签名证书导入到受信任证书列表中。 @kellen在此post on SO中发布了一个很好的教程。