前面已经安装好了apache2和ssl
首先建立自己的CA文件夹
CA/myCA
1.创建CA认证
找到
etc/ssl/openssl.cnf
COPY一份到myCA下面
修改其下的变量值
dir = /home/mocci/CA/myCA
建立相应的目录:
mkdir -p //home/mocci/CA/myCA/certs
mkdir -p /home/mocci/CA/myCA/newcerts
建立文件:
echo “01″ > /etc/ssl/CA/serial && touch index.txt
建立root CA的密匙,需要你建立一个CA的密码:
openssl genrsa -des3 2048 > ca.privatekey
openssl req -new -x509 -key ca.privatekey -days 3650 -out ca.cert
Country Name (2 letter code) [AU]:CN
State or Province Name (full name) [Some-State]:Zhejiang
Locality Name (eg, city) []:Hangzhou
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Mux Team
Organizational Unit Name (eg, section) []:muxcn
Common Name (eg, YOUR name) []:www.mux.net
Email Address []:ling2113@gmail.com
将创建的CA的密匙和自认证文件复制
cp ca.privatekey /etc/ssl/CA/private/cakey.pem
cp ca.cer /etc/ssl/CA/cacert.pem
CA搞定。
2. 建立apache的ssl认证
首先建立用户的密匙,需要你设置一个密码
openssl genrsa -des3 2048 > cassl.privatekey
然后生成CA认证的申请文件
openssl req -days 3650 -key cassl.privatekey -new -out cassl.csr
生成CA的认证文件
openssl ca -out cassl.pem -days 3650 -infiles cassl.csr
如果找不到的话,可以用
export OPENSSL_CONF=……
来设定你的CA路劲
cat cassl.privatekey cassl.pem > apache.pem
3. 配置apache2服务器
启动apache2下的mod_ssl
a2enmod ssl
复制apache.pem到/etc/apache2/ssl
建立CADOMAIN
进入/etc/apache2/sites-available/
cp default ssl
ln -s /etc/apache2/sites-available/ssl /etc/apache2/sites-enabled/ssl
修改ssl
NameVirtualHost *:443
<VirtualHost *:443>
Add the following two lines under the <VirtualHost *:443> line:
SSLEngine On
SSLCertificateFile /etc/apache2/ssl/apache.pem/
修改default和ssl
etc/apache2/sites-enabled/default
/etc/apache2/sites-enabled/ssl,
and modify the NameVirtualHost *
directive to resemble: NameVirtualHost *:80
and the VirtualHost * directive to resemble: <VirtualHost *:80>
添加https的监听端口443,
vi /etc/ports.conf
Listen 443
重启apache2
sudo /etc/init.d/apache2 force-reload
输入PASS,OK!!
测试
https://localhost/svn/myprojects
you must enable URL rewrite support in the Ubuntu Apache 2 package by executing the following command:
sudo a2enmod rewrite
You should receive the following output from the above command:
Module rewrite installed; run /etc/init.d/apache2 force-reload to enable.