如何利用openssl为iis生成ssl服务器证书
2011-03-25 17:25
676 查看
一、IIS服务器操作:
1.在要安装SSL服务的机器上,打开iis管理。2.在要安加SSL服务的网站,右键打开网站属性Table.
3.选取目录安全中的服务器证书.
4.进入生成服务器证书请求的步骤中,一步步填写相应的信息。每一步相应的信息要记住,这些信息在后面要用到。
二、openssl操作:
1.生成私钥。
openssl genrsa -des3 -out cakey.pem 2048
2.生成自签名根证书.
openssl req -new -x509 -key cakey.pem -out cacert.pem -days 1825
此处会要求输入一些信息:
Country Name: CN //两个字母的国家代号
State or Province Name: guang dong //省份名称
Locality Name: guang zhou //城市名称
Organization Name: sunrising //公司名称
Organizational Unit Name: home //部门名称
Common Name: besunny //你的姓名(要是生成服务器端的证书一定要输入域名或者ip地址)
切记一定要和IIS服务器上填写的信息保持一致。
3.在你的openssl主目录下的bin目录下创建如下目录:
demoCA
demoCA/private
demoCA/newcerts
在demoCA目录下创建一个空的index.txt文件.
在demoCA目录创建一个serial文件,文件内容为01 .
4.把第二步的生成的cakey.pem拷贝到 demoCA/private目录下; 把cacert.pem 拷贝到demoCA目录下.
5.用CA证书cacert.pem为IIS请求certreq.txt签发证书。(将iis服务器生成的certreq.txt存放在openssl/bin下面)
openssl ca -in certreq.txt -out iis.cer
6.打开iis.cer,删掉在"-- Begin Certificate --"的文本。
三.IIS服务器操作:
在该网站属性中目录安全的服务器证书 ,导入该证书。
四、测试是否SSL正常。
二、配置OpenSSL
1、建立自己的CA证书
在openssl的apps目录下建立自己的CA证书,例如mageCA
C:/openssl098b/apps>mkdir mageCA
2、生成CA密钥
C:/openssl098b/apps>openssl genrsa -out mageCA/ca-key.pem 1024
Genrsa[产生密钥命令] –out[密钥文件输出路径] 1024[密钥位数]
Loading 'screen' into random state - done
Generating RSA private key, 1024 bit long modulus
..............................++++++
......++++++
3、生成待签名的证书
C:/openssl098b/apps>openssl req -new -out mageCA/ca-req.csr -key mageCA/ca-key.pem
req[产生证书命令]-new[新生成]-out[证书文件输出路径]-key[私钥文件路径]
报错:
Using configuration from /usr/local/ssl/openssl.cnf
Unable to load config info
unable to find 'distinguished_name' in config
problems making Certificate Request
2188:error:0E06D06A:configuration file routines:NCONF_get_string:no conf or envi
ronment variable:./crypto/conf/conf_lib.c:344:
2188:error:0E06D06A:configuration file routines:NCONF_get_string:no conf or envi
ronment variable:./crypto/conf/conf_lib.c:344:
2188:error:0E06D06A:configuration file routines:NCONF_get_string:no conf or envi
ronment variable:./crypto/conf/conf_lib.c:344:
2188:error:0E06D06A:configuration file routines:NCONF_get_string:no conf or envi
ronment variable:./crypto/conf/conf_lib.c:344:
2188:error:0E06D06A:configuration file routines:NCONF_get_string:no conf or envi
ronment variable:./crypto/conf/conf_lib.c:344:
2188:error:0E06D06A:configuration file routines:NCONF_get_string:no conf or envi
ronment variable:./crypto/conf/conf_lib.c:344:
2188:error:0E06D06A:configuration file routines:NCONF_get_string:no conf or envi
ronment variable:./crypto/conf/conf_lib.c:344:
2188:error:0E06D06A:configuration file routines:NCONF_get_string:no conf or envi
ronment variable:./crypto/conf/conf_lib.c:344:
出现这样的问题后,打开了apps下的req查看DIAGNOSTICS:
=head1 DIAGNOSTICS
The following messages are frequently asked about:
?????? Using configuration from /some/path/openssl.cnf
?????? Unable to load config info
This is followed some time later by...
?????? unable to find 'distinguished_name' in config
?????? problems making Certificate Request
The first error message is the clue: it can't find the configuration
file! Certain operations (like examining a certificate request) don't
need a configuration file so its use isn't enforced. Generation of
certificates or requests however does need a configuration file. This
could be regarded as a bug.
依然不能解决问题,在网上搜索,被告知是环境变量没有设置,于是设置系统用户变量OPENSSL_CONF为C:/openssl098b/apps/openssl_cnf。重开一个命令行窗口,要求输入一系列的信息,如国家、省、市、公司、部门、姓名、电子邮件等,命令执行完成。
在设置了环境变量以后,一定要另开一个命令行窗口!一开始我就是没有另开窗口,所以后来又耽误了好多时间,不过,真是因为这个错误,我才搞清楚了openssl_cnf!
至于openssl_cnf,笨笨的我还在apps下找了好半天,都没有找到这个文件,后来被高手告知就是那个名为openssl的计算机图标一样的文件,是可以用写字板打开的!狂晕!
还有人说是在ssl目录下,但是我的不是!
4、用CA私钥自签名
C:/openssl098b/apps> openssl x509 -req -in ca/ca-req.csr -out ca/ca-cert.pem -signkey ca/ca-key.pem -days 365
x509[签发x509证书命令] -req[输入待签发证书] -in[输入待签发证书文件路径] -out[产生x509证书文件输出路径] -signkey[自签发密钥文件路径] -days[证书有效期]–CA[签发跟证书] -Cakey[根证书密钥文件] -CAcreateserial[创建序列号]
得到私钥。
参考网址:
如何设置客户端证书
http://www.microsoft.com/china/technet/security/guidance/secmod31.mspx在Windows XP下用openSSL 制作IIS证书 http://apps.hi.baidu.com/share/detail/14750908
我自己制作的SSL证书使用到的命令:
E:/SSL/GnuWin32/bin>openssl genrsa -out cakey.pem 1024
E:/SSL/GnuWin32/bin>openssl req -new -x509 -key cakey.pem -out cacert.pem -days
1825
E:/SSL/GnuWin32/bin>openssl ca -in certreq.txt -out iis.cer
相关文章推荐
- 如何利用openssl为iis生成ssl服务器证书!
- 如何配置证书服务器以便在 IIS 上与 SSL 结合使用
- 使用openssl生成ssl服务器请求证书解决中文乱码的问题
- java通过ssl连接LDAP服务器(包括LDAP服务器搭建、openssl数字证书生成、openldap服务器配置启动)
- 利用keytool/openSSL来生成服务器和客户端证书
- 【本地服务器】利用openssl生成证书
- 如何配置证书服务器以便在 IIS 上与 SSL 结合使用
- OpenSSL生成证书详解 如何使用OpenSSL生成自签证书 转载
- 利用OpenSSL生成的私钥、公钥和证书,用来验证文件是否被修改
- 利用openssl生成证书详细过程
- 使用OpenSSL生成自签名证书(IIS)搭建Https站点
- 利用openssl生成的https的ca来访问web服务器
- 如何部署SSL服务器证书更安全
- 利用证书实现windows 2003下IIS的SSL安全通信
- 如何使用OpenSSL工具生成根证书与应用证书
- OpenSSL生成证书详解 如何使用OpenSSL生成自签证书 转载
- openssl下生成建立CA并生成服务器和客户端证书方法
- 如何用openssl命令行生成证书
- 如何用openssl命令行生成证书