https://www.digitalocean.com/community/tutorials/how-to-create-a-ssl-certificate-on-apache-for-ubuntu-12-04
Apache2使能SSL,是Keystone使能SSL的第一步。
首先在ubuntu12.04上,apache2应该已经安装好了。如果未安装好,则通过如下命令安装:
sudo apt-get install apache2
1> 使能SSL模块
a2enmod ssl
重启apache2
service apache2 restart
2> 创建新的目录来保存server密钥和证书
mkdir /etc/apache2/ssl
3> 创建SSL自签名证书
创建证书有两种:一种是自签名证书,另外一种是第三方CA机构签名证书。第一种随便使用,只是没有经过官方认可的机构认证而已,后一种则是正规的签名证书,有发证机构签名。其实很多所谓的大网站上使用的SSL证书,一样都是自签名的,主要是因为这个证书只做为在线验证使用,保证传输数据安全即可,不过使用这种证书,对常规浏览器和一些软件而言,一般均会弹出警告,让你确认这个签名证书的有效性。正规签名证书也不过只是多了一重保障而已,而且浏览器、软件等可以自己鉴别。
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crtx509是常见的数字证书格式,
365: 证书有效期
rsa:2048:2048字节的rsa密钥
-keyout:输出密钥文件apache.key
-out:输出自签名证书文件apache.crt
执行这个命令,会需要你填入一些信息,其中需要注意的是“Common Name”,填入你的域名或者IP地址
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]:CH State or Province Name (full name) [Some-State]:SH Locality Name (eg, city) []:SH Organization Name (eg, company) [Internet Widgits Pty Ltd]:intel Organizational Unit Name (eg, section) []:it Common Name (e.g. server FQDN or YOUR name) []:10.239.131.210 Email Address []:webmaster@awesomeinc.com4> 设置证书
配置虚拟主机来显示新证书。修改ssl配置文件:
nano /etc/apache2/sites-available/default-ssl找到区域<VirtualHost _default_:443>,在ServerAdmin webmaster@localhost下面加上
ServerName 10.239.131.210:443
这里的10.239.131.210是你的IP地址(与上面填的comman name应该一样)
找到下面几行,使它们如下:
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
保存并退出文件。
5> 激活新的虚拟主机
a2ensite default-ssl
apache2重载所有修改
service apache2 reload
补充:http://blog.sina.com.cn/s/blog_83f6c94c0101e96h.html
证书的概念:首先要有一个根证书,然后用根证书来签发服务器证书和客户证书,一般理解:服务器证书和客户证书是平级关系。在SSL必须安装根证书和服务器证书来认证。
因此:在此环境中,至少必须有三个证书:即根证书,服务器证书,客户端证书
在生成证书之前,一般会有一个私钥,同时用私钥生成证书请求,再利用证书服务器的根证来签发证书。
常见数字证书格式
PKCS——RSA实验室与其他安全系统开发商为促进公钥密码发展指定的一系列标准
x.509