apache配置https协议常见问题解析
2017-07-11 18:30
603 查看
配置https协议:
1、安装好apache环境,注意要装ssl版本的。这里装在c:/apache目录下。
2、生成服务器证书
1)在DOS命令下进入apache/bin目录
2)在windows环境下需先设置Openssl环境变量:
执行命令
[plain] view
plaincopy
set OPENSSL_CONF=..\conf\openssl.cnf
请在执行之前确保 openssl.cnf 存在,否则会出现:WARNING: can't open config file: /usr/local/ssl/openssl.cnf 信息提示。
还有在windows系统下.cnf 默认会被当成快捷方式,看不到扩展名。
3)生成私钥文件:
执行命令
[plain] view
plaincopy
openssl genrsa 1024>server.key
说明:这是用128位rsa算法生成密钥,得到server.key文件。 > 是输出文件的标识符
这种生成方法生成的是没有密钥的私钥文件。当然,Apache提供了加入密钥(Password)的命令,就是加入参数-des3。命令为:
[plain] view
plaincopy
openssl genrsa 1024 -des3 > server.key
使用上述命令生成私钥文件是需要输入密钥的,运行的时候会让你输入并确认你的密钥。但是在Windows环境下会导致以下错误:错误:Apache启动失败,错误提示是:Init:
SSLPassPhraseDialog builtin is not supported on Win32 (key file .....)
原因是window下的apache不支持加密的私钥文件。
注:生成的证书中RSA密钥对的默认长度是1024,取值是2的整数次方。建议使用4096以上。
4)生成证书请求文件。
执行命令
[plain] view
plaincopy
openssl req -new -key server.key > server.csr
说明:这是用步骤3的密钥生成证书请求文件server.csr, 这一步会有很多参数,需要一一输入。
按提示输入一系列的参数:
Country Name (2 letter code) [AU]:CN ISO国家代码(只支持两位字符)
State or Province Name (full name) [Some-State]:ZJ所在省份
Locality Name (eg, city) []:HZ所在城市
Organization Name (eg, company):SW_TECH公司名称
Organizational Unit Name (eg, section) []:SW_TECH组织名称
Common Name (eg, YOUR name) []:kedou.com申请证书的域名
Email Address []:admin@admin.com 管理员邮箱
Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: 交换密钥
An optional company name []: 注:Common Name必须和httpd.conf中server name必须一致,否则apache不能启动 (启动apache时错误提示为:RSA server certificate CommonName (CN) `Kedou' does NOT match server name!? )
5)签署服务器证书文件。
执行命令行
[plain] view
plaincopy
openssl req -x509 -days 365 -key server.key -in server.csr > server.crt
说明:这是用步骤3,4的的密钥和证书请求生成证书server.crt,-days参数指明证书有效期,单位为天,x509表示生成的为X.509证书。
以上签署证书仅仅做测试用,真正运行的时候,应该将CSR发送到一个CA返回真正的证书。网上有些文档描述生成证书文件的过程比较繁琐,就是因为 他们自己建立了一个CA中心,然后再签署server.csr
用openssl x509 -noout -text -in server.crt 可以查看证书的内容。证书实际上包含了Public Key
3、配置httpd.conf
打开httpd.conf文件,移除注释的行:
[plain] view
plaincopy
Include conf/extra/httpd-ssl.conf
LoadModule ssl_module modules/mod_ssl.so
打开httpd-ssl.conf,修改如下:
[plain] view
plaincopy
<VirtualHost _default_:443>
SSLEngine On
SSLCertificateFile ../bin/server.crt
SSLCertificateKeyFile ../bin/server.key
#SSLCertificateChainFile ../bin//ca.crt // 暂未启用
#......
DocumentRoot "c:/apache/htdocs"
ServerName www.kedou.com:443
</VirtualHost>
4、重启apahce服务,访问https://localhost,完工!
===========出现错误汇集==========
1,、"Syntax error on line 80 of c:/apache/conf/extra/httpd-ssl.conf:ErrorLog takes one argument,The filename of the error log"或者"Syntax error on line 99 of c:/apache/conf/extra/httpd-ssl.conf:SSLCertificateFile takes one argument,SSL Server Certificate file
('/path/to/file' -PEM or DER encoded)"
解决方法:文件路径加双引号
2、"Syntax
error on line 76 of C:/apache/conf/extra/httpd-ssl.conf:
解决办法:
打开httpd.conf,找到 LoadModule
socache_shmcb_module modules/mod_socache_shmcb.so,把前面的注释去掉。
转自:http://blog.csdn.net/damys/article/details/38434177
1、安装好apache环境,注意要装ssl版本的。这里装在c:/apache目录下。
2、生成服务器证书
1)在DOS命令下进入apache/bin目录
2)在windows环境下需先设置Openssl环境变量:
执行命令
[plain] view
plaincopy
set OPENSSL_CONF=..\conf\openssl.cnf
请在执行之前确保 openssl.cnf 存在,否则会出现:WARNING: can't open config file: /usr/local/ssl/openssl.cnf 信息提示。
还有在windows系统下.cnf 默认会被当成快捷方式,看不到扩展名。
3)生成私钥文件:
执行命令
[plain] view
plaincopy
openssl genrsa 1024>server.key
说明:这是用128位rsa算法生成密钥,得到server.key文件。 > 是输出文件的标识符
这种生成方法生成的是没有密钥的私钥文件。当然,Apache提供了加入密钥(Password)的命令,就是加入参数-des3。命令为:
[plain] view
plaincopy
openssl genrsa 1024 -des3 > server.key
使用上述命令生成私钥文件是需要输入密钥的,运行的时候会让你输入并确认你的密钥。但是在Windows环境下会导致以下错误:错误:Apache启动失败,错误提示是:Init:
SSLPassPhraseDialog builtin is not supported on Win32 (key file .....)
原因是window下的apache不支持加密的私钥文件。
注:生成的证书中RSA密钥对的默认长度是1024,取值是2的整数次方。建议使用4096以上。
4)生成证书请求文件。
执行命令
[plain] view
plaincopy
openssl req -new -key server.key > server.csr
说明:这是用步骤3的密钥生成证书请求文件server.csr, 这一步会有很多参数,需要一一输入。
按提示输入一系列的参数:
Country Name (2 letter code) [AU]:CN ISO国家代码(只支持两位字符)
State or Province Name (full name) [Some-State]:ZJ所在省份
Locality Name (eg, city) []:HZ所在城市
Organization Name (eg, company):SW_TECH公司名称
Organizational Unit Name (eg, section) []:SW_TECH组织名称
Common Name (eg, YOUR name) []:kedou.com申请证书的域名
Email Address []:admin@admin.com 管理员邮箱
Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: 交换密钥
An optional company name []: 注:Common Name必须和httpd.conf中server name必须一致,否则apache不能启动 (启动apache时错误提示为:RSA server certificate CommonName (CN) `Kedou' does NOT match server name!? )
5)签署服务器证书文件。
执行命令行
[plain] view
plaincopy
openssl req -x509 -days 365 -key server.key -in server.csr > server.crt
说明:这是用步骤3,4的的密钥和证书请求生成证书server.crt,-days参数指明证书有效期,单位为天,x509表示生成的为X.509证书。
以上签署证书仅仅做测试用,真正运行的时候,应该将CSR发送到一个CA返回真正的证书。网上有些文档描述生成证书文件的过程比较繁琐,就是因为 他们自己建立了一个CA中心,然后再签署server.csr
用openssl x509 -noout -text -in server.crt 可以查看证书的内容。证书实际上包含了Public Key
3、配置httpd.conf
打开httpd.conf文件,移除注释的行:
[plain] view
plaincopy
Include conf/extra/httpd-ssl.conf
LoadModule ssl_module modules/mod_ssl.so
打开httpd-ssl.conf,修改如下:
[plain] view
plaincopy
<VirtualHost _default_:443>
SSLEngine On
SSLCertificateFile ../bin/server.crt
SSLCertificateKeyFile ../bin/server.key
#SSLCertificateChainFile ../bin//ca.crt // 暂未启用
#......
DocumentRoot "c:/apache/htdocs"
ServerName www.kedou.com:443
</VirtualHost>
4、重启apahce服务,访问https://localhost,完工!
===========出现错误汇集==========
1,、"Syntax error on line 80 of c:/apache/conf/extra/httpd-ssl.conf:ErrorLog takes one argument,The filename of the error log"或者"Syntax error on line 99 of c:/apache/conf/extra/httpd-ssl.conf:SSLCertificateFile takes one argument,SSL Server Certificate file
('/path/to/file' -PEM or DER encoded)"
解决方法:文件路径加双引号
2、"Syntax
error on line 76 of C:/apache/conf/extra/httpd-ssl.conf:
SSLSessionCache:
'shmcb'
session cache not supported (known names: ). Maybe you need to load the appropriate socache module (mod_socache_shmcb?)."
解决办法:
打开httpd.conf,找到 LoadModule
socache_shmcb_module modules/mod_socache_shmcb.so,把前面的注释去掉。
转自:http://blog.csdn.net/damys/article/details/38434177
相关文章推荐
- apache配置https协议
- Apache配置HTTPS协议搭载SSl配置全过程
- apache配置https协议
- Tomcat下基于HTTPS协议应用的负载均衡配置问题
- Apache配置HTTPS协议搭载SSl配置全过程
- 部署apache+mod_python+Django 应用常见的配置问题
- Apache配置HTTPS协议搭载SSl配置全过程
- apache配置https协议
- Apache配置https协议
- Apache 配置HTTPS协议搭载SSL配置
- HTTP协议及Apache配置解析
- Apache配置HTTPS协议搭载SSl配置全过程
- Apache 配置HTTPS协议搭载SSL配置
- WAMP(Windows、Apache、MySQL、php)安装配置过程常见问题
- Ubuntu上配置SVN,Apache服务以及常见问题解决方法
- linux 内核编译:内核配置原理与常见配置问题的解决方法&&内核版本控制解析
- Apache+PHP配置过程详解以及常见问题
- [转]配置Apache服务器支持https协议和SSL证书
- 在linux下的apache配置https协议,开启ssl连接