我被要求在Apache上的localhost上使用自签名证书设置HTTPS,但我实际上如何做到这一点?我完全不知道。
当前回答
我想在@CodeWarrior的非常好的回答中添加一些东西,这在Chrome上完美地工作,但对于Firefox需要额外的步骤。
由于Firefox不支持默认情况下Windows提供的CA证书,您需要继续:config,向下滚动到security.enterprise_root。Enabled并将其更改为true。
现在,您的证书在Firefox上也应该是有效的。
当然,这仅用于开发目的,因为ssl信任是一个关键的安全问题,只有在知道其影响时才更改此设置。
其他回答
这应该是工作Ubuntu,薄荷类似于Apache2
这是一个很好的指南,所以遵循这个
https://www.digitalocean.com/community/tutorials/how-to-create-a-ssl-certificate-on-apache-for-ubuntu-14-04
然后像这样留下ssl。conf
<VirtualHost _default_:443>
ServerAdmin your@email.com
ServerName localhost
ServerAlias www.localhost.com
DocumentRoot /var/www
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
你可以得到它。
希望这对linuxer有帮助
这实际上很简单,假设您手边有一个openssl安装。(您在哪个站台?)
假设你使用的是linux/solaris/mac os/x, Van的Apache SSL/TLS mini-HOWTO有一个很好的演练,我在这里就不再赘述了。
但是,执行摘要是您必须创建一个自签名证书。由于您运行apache for localhost大概是为了开发(即不是公共web服务器),您将知道您可以信任自签名证书,并且可以忽略浏览器抛出的警告。
我想在@CodeWarrior的非常好的回答中添加一些东西,这在Chrome上完美地工作,但对于Firefox需要额外的步骤。
由于Firefox不支持默认情况下Windows提供的CA证书,您需要继续:config,向下滚动到security.enterprise_root。Enabled并将其更改为true。
现在,您的证书在Firefox上也应该是有效的。
当然,这仅用于开发目的,因为ssl信任是一个关键的安全问题,只有在知道其影响时才更改此设置。
Windows + Apache 2.4,例如:
uncomment ssl_module in your httpd.conf file. LoadModule ssl_module modules/mod_ssl.so listen 443 port just like 80 port in your httpd.conf file. Listen 80 Listen 443 uncomment Include Virtual hosts in your httpd.conf file. # Virtual hosts Include conf/extra/httpd-vhosts.conf add VirtualHost in your conf/extra/httpd-vhosts.conf <VirtualHost _default_:443> DocumentRoot "D:/www" #your site directory path ServerName localhost #ServerAlias localhost.com localhost2.com SSLEngine on SSLCertificateFile "${SRVROOT}/conf/ssl/server.crt" SSLCertificateKeyFile "${SRVROOT}/conf/ssl/server.key" <Directory "D:/www"> Options -Indexes +FollowSymLinks +ExecCGI AllowOverride All Require all granted </Directory> </VirtualHost>
只有端口号443和SSL......行与正常的HTTP配置不同。
保存配置文件并重新启动apache服务。然后你可以访问https://localhost/
浏览器会在第一时间警告你这是不安全的,选择继续。
这个HowTo for CentOS很简单,只花了大约5分钟:https://wiki.centos.org/HowTos/Https
我不会在这里详细介绍每一步,但主要步骤如下:
1)。安装apache的openssl模块(如果尚未安装)
2)。生成自签名证书
—此时,您应该能够成功访问https://localhost
3)。如果需要,可以设置一个虚拟主机
推荐文章
- 证书验证失败:无法获得本地颁发者证书
- 当使用pip3安装包时,“Python中的ssl模块不可用”
- 如何从同一网络上的另一台计算机连接到此本地主机?
- 在Cygwin中对HTTPS URL运行wget时,如何修复证书错误?
- CFNetwork SSLHandshake iOS 9失败
- HTTPS和SSL3_GET_SERVER_CERTIFICATE:证书验证失败,CA is OK
- c#忽略证书错误?
- 如何找出如果你使用HTTPS没有$_SERVER['HTTPS']
- 最好的方法在asp.net强制https为整个网站?
- 127.0.0.1和localhost之间的区别是什么
- 如何允许本地主机上的Apache使用HTTPS ?
- XAMPP -端口80被PID 4的“无法打开进程”使用!12
- 如何让Chrome允许混合内容?
- 无法识别的SSL消息,明文连接?异常
- 为什么对Apache提供的文本文件使用deflate而不是gzip ?