rh333 - 利用apache搭建简易https服务器
来源:互联网 发布:mac air 文件夹整理 编辑:程序博客网 时间:2024/05/29 12:17
rh333 - 利用apache搭建简易https服务器
安装httpd以及ssl包
yum install httpd mod_ssl -y
生成web服务器私钥和证书请求文件(csr)
cd /etc/httpd/conf/
openssl genrsa out httpd.key 1024
openssl req -new -key httpd.key -out httpd.csr
使用自建的CA中心签名web服务器公钥
cd /etc/httpd/conf/
openssl ca -in httpd.csr -out httpd.crt
如何搭建CA中心请参考:
rh333 - 搭建简易CA中心
http://blog.csdn.net/t0nsha/article/details/8816288
配置apache启用ssl支持
<VirtualHost 192.168.0.20:443>
DocumentRoot /var/www/html/www20
ServerName www20.example.com
SSLEngine on
SSLCertificateFile /etc/httpd/conf/httpd.crt
SSLCertificateKeyFile /etc/httpd/conf/httpd.key
</VirtualHost>
重起httpd服务并测试
/etc/init.d/httpd restart
查看已签名证书的指纹
openssl x509 -fingerprint -in httpd.crt -noout -sha1
openssl x509 -fingerprint -in httpd.crt -noout -md5
使用openssl验证ssl连接
openssl s_client -connect www20.example.com:443 -CAfile my-ca.crt
...
Verify return code: 0 (ok) #返回这行表示使用了CA签名的证书
使用Firefox倒入ca中心证书,然后访问ssl加密站点https://www20.example.com,
如果能够正常显示index.html内容并且没有其他错误或者提示则表示配置正确。
碰到的一些错误:
1. DocumentRoot改动无效
原因: 如果没有具体化VirtualHost,则会一直使用默认的DocumentRoot(/var/www/html),忽略VirtualHost中的DocumentRoot。
解决方法: 将<VirtualHost *:443> 改为 <VirtualHost 192.168.0.20:443>
2. Firefox安装了CA中心证书后,仍然报证书不可信任(sec_error_unknow_issuer),检查配置信息没有错误.
原因: 可能来自服务段也可来自客户端:Apache服务器端启用了非CA中心签名的证书;客户端使用错误的CA中心公钥.
解决方法: 确保服务段使用了正确的公私钥, 确保客户端倒入了正确的CA中心证书.
查看Firefox证书的证书,如果发行信息如下,则表示启用系统自带的localhost证书
(/etc/pki/tls/certs/locahost.crt, /etc/pki/tls/private/locahost.key)
OU = SomeOrganizationalUnit O = SomeOrganization L = SomeCity S = SomeState
解决方法是注释掉/etc/httpd/conf.d/ssl里面有关这对自带公私钥的两行或者将VirtualHost后面的*改为具体IP地址.
REF:
1. VirtualHost Examples
http://httpd.apache.org/docs/2.2/vhosts/examples.html
安装httpd以及ssl包
yum install httpd mod_ssl -y
生成web服务器私钥和证书请求文件(csr)
cd /etc/httpd/conf/
openssl genrsa out httpd.key 1024
openssl req -new -key httpd.key -out httpd.csr
使用自建的CA中心签名web服务器公钥
cd /etc/httpd/conf/
openssl ca -in httpd.csr -out httpd.crt
如何搭建CA中心请参考:
rh333 - 搭建简易CA中心
http://blog.csdn.net/t0nsha/article/details/8816288
配置apache启用ssl支持
<VirtualHost 192.168.0.20:443>
DocumentRoot /var/www/html/www20
ServerName www20.example.com
SSLEngine on
SSLCertificateFile /etc/httpd/conf/httpd.crt
SSLCertificateKeyFile /etc/httpd/conf/httpd.key
</VirtualHost>
重起httpd服务并测试
/etc/init.d/httpd restart
查看已签名证书的指纹
openssl x509 -fingerprint -in httpd.crt -noout -sha1
openssl x509 -fingerprint -in httpd.crt -noout -md5
使用openssl验证ssl连接
openssl s_client -connect www20.example.com:443 -CAfile my-ca.crt
...
Verify return code: 0 (ok) #返回这行表示使用了CA签名的证书
使用Firefox倒入ca中心证书,然后访问ssl加密站点https://www20.example.com,
如果能够正常显示index.html内容并且没有其他错误或者提示则表示配置正确。
碰到的一些错误:
1. DocumentRoot改动无效
原因: 如果没有具体化VirtualHost,则会一直使用默认的DocumentRoot(/var/www/html),忽略VirtualHost中的DocumentRoot。
解决方法: 将<VirtualHost *:443> 改为 <VirtualHost 192.168.0.20:443>
2. Firefox安装了CA中心证书后,仍然报证书不可信任(sec_error_unknow_issuer),检查配置信息没有错误.
原因: 可能来自服务段也可来自客户端:Apache服务器端启用了非CA中心签名的证书;客户端使用错误的CA中心公钥.
解决方法: 确保服务段使用了正确的公私钥, 确保客户端倒入了正确的CA中心证书.
查看Firefox证书的证书,如果发行信息如下,则表示启用系统自带的localhost证书
(/etc/pki/tls/certs/locahost.crt, /etc/pki/tls/private/locahost.key)
OU = SomeOrganizationalUnit O = SomeOrganization L = SomeCity S = SomeState
解决方法是注释掉/etc/httpd/conf.d/ssl里面有关这对自带公私钥的两行或者将VirtualHost后面的*改为具体IP地址.
REF:
1. VirtualHost Examples
http://httpd.apache.org/docs/2.2/vhosts/examples.html
- rh333 - 利用apache搭建简易https服务器
- rh333 - 搭建简易CA中心
- Apache搭建https服务器ssl
- 利用树莓派搭建简易服务器
- Linux搭建apache简易媒体服务器
- linux 搭建https 服务器 (apache)
- Windows搭建Apache+SSL Https服务器
- 利用Python搭建简易的Http服务器
- Mac Apache服务器搭建、Tomcat(http)服务器搭建、Tomcat(https)服务器搭建
- windows下面配置apache+https(利用SSL)服务器
- windows下面配置apache+https(利用SSL)服务器
- windows下面配置apache+https(利用SSL)服务器
- wampserver 使用openssl和apache搭建https服务器教程
- 阿里云服务器搭建apache+https+集群tomcat
- 简易apache Server 服务器
- Ubuntu下 利用httpd和OpenSSL搭建HTTPS web服务器
- 搭建简易Samba服务器
- wap服务器简易搭建
- rh333 - 搭建简易CA中心
- 关于AutoCompleteTextView 为什么必须输入两个字符才能出现补全提示的问题的解决办法
- Minimum Inversion Number HDU 1394
- lazyFrameWork懒人开发平台拉开序幕篇
- 每天看一次 不久你就会变
- rh333 - 利用apache搭建简易https服务器
- 懒加载3种解决方案
- android自定义Spinner下拉菜单和AutoCompleteTextView自动显示的(下拉列表框)样式
- ASP.NET几种清除页面缓存的方法
- ckeditor 在C#中使用
- python获取硬件信息
- 看观察者怎么全方位观察机房收费系统
- JS中比较两个变量值的大小
- Zstack设置发送功率(CC2530)