LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
12
返回列表 发新帖
楼主: laoang

RHEL4 中apache+openssl配置特殊问题!

[复制链接]
发表于 2006-8-3 03:26:25 | 显示全部楼层

Apache生成密匙及发送CA(原创)

如果你是想做测试或本地实验用跳过步骤1-4

1. 删除Apache默认密匙或原有密匙
  
     # rm /etc/httpd/conf/ssl.key/server.key
     # rm /etc/httpd/conf/ssl.crt/server.crt

2.创建自己随机数产生的密匙

  2-1 # /usr/bin/openssl genrsa 1024 >                               /etc/httpd/conf/ssl.key/server.key
   
   如果你想生成带口令(Passphrase)的密匙,跳过上述步骤执行

  2-2 # cd /usr/share/ssl/certs
      # make genkey

   两次输入密码,以后每次重起Apache时都要此密码.

3.生成server.csr文件

  3-1 (用于联接步骤2-1)

    # /usr/bin/openssl req -new -key /etc/httpd/conf/ssl.key/server.key -out /etc/httpd/conf/ssl.csr/server.csr

   3-2 (用于联接步骤2-2)
   
    # cd /usr/share/ssl/certs
    # make certreq

    在步骤3中填写服务器详悉管理信息后,此时生成/etc/httpd/conf/ssl.csr/server.csr把它作为请求的一部 分发送给CA.
  
4.联机发送/etc/httpd/conf/ssl.csr/server.csr到CA.需等待一定时间以供CA审查所提交的信息,通过审查后,CA会将数字证书以邮寄磁盘或EMAIL或在线下载的方式来授予.收到CA的证书后保存在
/etc/httpd/conf/ssl.crt/目录.重起Apache即可.

5.如果你是想做测试或本地实验用
   
   # rm /etc/httpd/conf/ssl.key/server.key
   # rm /etc/httpd/conf/ssl.crt/server.crt
   # /usr/bin/openssl genrsa 1024 >                              /etc/httpd/conf/ssl.key/server.key
   # cd /usr/share/ssl/certs
   # make testcert
   # service httpd restart


(注: /etc/httpd/conf/ssl.key/server.key 为生成Apache密匙文件.

    /etc/httpd/conf/ssl.csr/server.csr  为向CA提交的服务器详悉管理信息.

    /etc/httpd/conf/ssl.crt/server.crt   CA颁发的或用于测试用的数字证书. )
回复 支持 反对

使用道具 举报

发表于 2006-8-3 03:47:58 | 显示全部楼层
问问,这个能否解决密码提示这个问题?
回复 支持 反对

使用道具 举报

发表于 2006-9-26 13:29:38 | 显示全部楼层
Post by 终极幻想
问问,这个能否解决密码提示这个问题?


        RPM安装httpd+openssl+mod_ssl后生成密钥、CSR、CA和证书过程
一、制作密钥(私钥)
1、cd /etc/httpd/conf/ssl.key
2、openssl genrsa [-des3] –out test.local.key [1024]
二、生成CSR
1、cd ../ssl.scr
2、openssl req –new –key ../ssl.key/test.local.key –out ./test.local.csr
三、创建CA
1、cd /etc/httpd/conf/ssl.prm
2. /usr/share/ssl/misc/CA –newca
此时,会在/etc/httpd/conf/ssl.prm/demoCA目录下生成CA公钥(cacert.prm),私钥(private/cakey.prm),以及目录certs,crl,newcerts,private, 文件index.txt和serial 。
四、用CA密钥签发CSR请求,生成CRT证书
1、cd /etc/httpd/conf/ssl.prm
2. openssl ca –in ../ssl.csr/test.local.csr –out ../ssl.crt/test.local.crt –days 365 –config /usr/share/ssl/openssl.cnf
还可以用参数-keyfile来指定CA密钥(cakey.prm)的位置,-cert来指定CA证书(cacert.prm)的位置。可以通过openssl ca –help来看帮助。
或者,自签发CRT证书:1)cd /etc/httpd/conf ; 2) openssl req –x509 –key ./ssl.key/test.local.key –in ./ssl.csr/test.local.csr –out ./ssl.crt/test.local.crt
至此,我们已经为apache生成了SSL密钥、CSR和CRT了。
五、设置ssl.conf文件
编辑/etc/httpd/conf.d/ssl.conf文件,修改
SSLCertificateFile  (CRT路径)
SSLCertificateKeyFile (私钥路径)
增加 SSLProtocol all
同时,把<VirtualHost >段修改
六、测试

        源代码包安装步骤 RHEL4中的试验(当前目录/usr/local/src)
首先,下载且解压包到/usr/local/src目录下
1、        编译openssl
cd openssl
./configure –prefix=/usr/local/openssl
make
make install
2. 编译mod_ssl
./configure –with-apache=../apache
3. 编译apache
SSL_BASE=../openssl  ./configure --enable-module=ssl(或者so) –prefix=/usr/local/apache (apache2.0以上版本用--enable-so,而不是–enable-module)
make (这里容易出错)
make certificate
make install
回复 支持 反对

使用道具 举报

发表于 2006-10-3 11:47:08 | 显示全部楼层
关键是apache在启动的时候, 如果私钥是通过passphrase encode过的, 那么它会提示需要密码, 所以可以制作不需要passphrase的私钥


  1. openssl genrsa -out server.key 1024
复制代码


也可以将有passphrase的私钥转换一下


  1. openssl rsa -in encoded.key -out noencoded.key
复制代码
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表