一、准备工作:
1.获取Apache2.2 for Win32。例如 apache_2.2.8-win32-x86-openssl-0.9.8g.msi
2.获取OpenSSL,如果下载的Aapche 2.2 for Win32已经包含OpenSSL则不用重复下载。
二、安装Apache2.2——这个我早就安装了,但是不带SSL的。可以将ssleay32.dll和libeay32.dll两个库和openssl.exe集中到一个地方,下一步要用。
三、获取SSL用到server.crt(证书)和server.key(密钥)。这个时候我们还需要一个 openssl.cnf 配置文件。一般 openssl 包都会自带,例如 Apache2.2.x with SSL就有。
1.执行 openssl req -new -out server.csr -config openssl.cnf ,会提示你输入一些内容,其中
Loading \'screen\' into random state - done
Generating a 1024 bit RSA private key
....................++++++
....++++++
writing new private key to \'privkey.pem\'
Enter PEM pass phrase: none
Verifying - Enter PEM pass phrase: none
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter \'.\', the field will be left blank.
-----
Country Name (2 letter code) [AU]:CN
State or Province Name (full name) [Some-State]:GUANGDONG
Locality Name (eg, city) []:FOSHAN
Organization Name (eg, company) [Internet Widgits Pty Ltd]:CCJTJ
Organizational Unit Name (eg, section) []:OFFICE
Common Name (eg, YOUR name) []:192.168.1.39 (这里要输入要做SSL的主机地址,或者域名)
Email Address []:
Please enter the following \'extra\' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
以上输入完后,可以得到一个 server.csr 和 privkey.pem,
2.执行openssl rsa -in privkey.pem -out server.key 生成服务器密钥 server.key
Enter pass phrase for privkey.pem: none (跟第1步输入的PEM pass phrase一样)
writing RSA key
3.执行 openssl x509 -in server.csr -out server.crt -req -signkey server.key -days 3650 ,创建自签证书 server.crt
四、完成之后,将生成的server.crt和server.key这两个文件拷贝到apache的conf目录下
五、修改Apache配置文件:
1.conf/httpd.conf
LoadModule ssl_module modules/mod_ssl.so
Include conf/extra/httpd-ssl.conf
2.conf/extra/httpd-ssl.conf
# General setup for the virtual host
DocumentRoot \"D:/webs/projects_5\" //修改成https方式的默认文件夹
ServerName www.open-src.com:443 //这个应该不一定改为同上面输入的Common Name一样。只要访问时输入 https://common name/ 并不会提示证书无效
六、重启Apache服务,应该可以通过 https 访问了
在网上有些参考文章中,是要对 httpd-ssl.conf 做一些修改的。但是我对照过,都是修改成默认值。如果按照以上步骤来操作,则不需要修改其他东西了。
另外一点就是要深化一下,注意上面的
没有评论:
发表评论