作者:Calf < https://www.calf.one >
https即将成为主流,作为跟风猪,怎么能不跟上潮流呢?本屌一向爱吃免费午餐,对于一年最低几百大洋的收费SSL一概忽略,于是乎找到了StartSSL的免费SSL。官方网站:https://www.startssl.com/
Calf 提示:点击图片可查看大图
-
选择“Start Now for Free SSL Certificate”
-
新用户选择“Sign up”;
-
接下来选择国家以及输入你的邮箱地址,然后点Sent verification code ,系统会发送你个确认码到邮箱;
-
在收到确认码之后填入接下来的对话框,点确定之后,网站给你安装好浏览器证书
-
接下来选择右下角的“Click here to choose your certificate.”创建免费SSL
-
选择“Web Server SSL/TLS Certificate” — > ” Continue “
-
会出现没有生效的域名,我们点”Domain Validation“去核验域名先。
-
输入有效的域名,再“Continue”
-
之后网站会检测你注册域名时留下的邮箱,还有常用的管理员邮箱列表。选择一个有效的邮箱,在点“Send Verification Code”,之后进入你的邮箱,复制授权码填入下面的对话框,再点“Validation ”。
-
核验域名成功,继续“ To “Order SSL Certificate”
-
在域名列表Validated domain(s)列表框填入你的其它子域名,比如:www.calf.one,每一个子域名一行。StartSSL免费SSL不支持*.domain.com格式。
往下拉,开始创建私钥。进入linux主机,运行命令:openssl req -newkey rsa:2048 -keyout yourname.key -out yourname.csr 在“Enter PEM pass phrase:” 输入密码,之后再确认输入一次。
-
接下来就是证书的相关信息了,按照自己的需要填。
[email protected]:/home/calf# openssl req -newkey rsa:2048 -keyout calf.key -out calf.csr
Generating a 2048 bit RSA private key
..+++
……………………………………………………………………………………………………………………+++
writing new private key to ‘calf.key’
Enter PEM pass phrase:
Verifying – Enter PEM pass phrase:
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) []:ShenZhen #城市
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Calf Blog #机构名
Organizational Unit Name (eg, section) []:Calf Blog #部门
Common Name (e.g. server FQDN or YOUR name) []:Calf #服务器名或个人名
Email Address []:[email protected] #邮件地址
Please enter the following ‘extra’ attributes
to be sent with your certificate request
A challenge password []:Calf.one #通讯“质询”密码
An optional company name []: #选填(可选项目:公司名)
-
之后在我的目录下生成了两个文件calf.key,calf.csr,打开calf.csr,将里面的内容复制到StartSSL网站的对话框里。再点“Submit”提交。
-
接下来等一下,网站会制作好证书,在接下来的页面点“please click here ”下载证书。
-
会得到一个压缩包,包里有不同服务器的证书,我的这里是选Apache,进入apache的包,解压两个证书文件(1_root_bundle.crt,2_www.网站名.crt),将他们上传到自己的网站上。
- 还有个很重要的步骤,解密私钥,不解密私钥的话,每次apache启动要会要求输密码。进入StartSSL的ToolBox,选择“Decrypt Private Key” ,
-
打开第一步创建的calf.key文件,将里面的内容复制到StartSSL网站的第一个大对话框里,下面的Passphrase:对话输入创建私钥时输入的密码(不是Challenge password),再点“Decrypt”解密。
-
解密之后会在下面显示解密后的内容,将他们复制下来,然后在主机里新建一个文件,粘贴内容进去,保存为calf_decrypt.key(名字自己随便起)。提示:你也可以在本地计算机新建文件再保存上传到网站上去,不过要注意的是最好不要用记事本保存。最好是SSH到主机上,用vi去保存文件。
- 接下来启用apache的SSL模块,命令:a2enmod ssl
- 修改apache的SSL配置文件:/etc/apache2/site-available/default-ssl.conf,将SSL证书路径指向你的三个文件。
注意 SSLEngine on。
SSLCertificateFile /home/calf/SSL/2_www.calf.one.crt #StartSSL下载的压缩包里面的“2_www.网站名.crt”
SSLCertificateKeyFile /home/calf/SSL/www.calf.one.key #解密后保存的私钥文件
SSLCertificateChainFile /home/calf/SSL/1_root_bundle.crt #StartSSL下载压缩包里的文件
-
设置完后重启apache2即可!service apache2 restart
OK,鸡冻人心的时候到了,输入https://www.calf.one可以看到绿色的锁了。逼格瞬间提升了有没有?! 🙂
Apache2如何强制http转https:https://www.calf.one/blog/apache2-force-use-https-4255.html
艾玛!做中英文图文blog真心不容易!!!
Leave a comment