简单介绍

HTTPS经由HTTP进行通信,但利用SSL/TLS来加密数据包。HTTPS开发的主要目的,是提供对网站服务器的身份认证,保护交换数据的隐私与完整性。这个协议由网景公司(Netscape)在1994年首次提出,随后扩展到互联网上。简单来说,相比于普通的HTTP来说,HTTPS更加安全可靠,避免了运营商劫持DNS向网站访问者强行加入广告,并且减少了信息泄露的可能性。
Let's Encrypt是一个免费、开放的SSL证书颁发机构,由 ISRG(Internet Security Research Group)运作。相比于动辄几十美元的SSL证书来说,免费的Let's Encrypt的SSL证书申请安装过程方便简单,更加适合个人博客等小网站使用。

安装教程

很多Let's Encrypt SSL证书安装教程都使用Certbot客户端甚至是手动安装,对于新手来说很麻烦,不具有高可操作性。下面展示如何使用Let's Encrypt自带的脚本一键安装SSL证书。
1.前期准备工作
以debian9 amd64位系统为例,root权限,其他linux系统操作相同

apt install git -y  //安装git工具,用于下载github上的源代码
mkdir ssl && cd ssl  //新建一个文件夹并进入

2.安装并配置ssl
首先下载源代码,然后进入文件夹运行脚本。

git clone https://github.com/letsencrypt/letsencrypt
cd letsencrypt
./letsencrypt-auto

然后就会出现各种配置操作:
输入一个你常用的邮箱以接收后面续期的提醒邮件。

Plugins selected: Authenticator apache, Installer apache
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): mail@example.com

询问是否接受服务协议,这里肯定是同意的。

Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.1.1-August-1-2016.pdf. You must agree
in order to register with the ACME server at
https://acme-v01.api.letsencrypt.org/directory
-------------------------------------------------------------------------------
(A)gree/(C)ancel: A

选择是否接受他们的一些通知类邮件,此选择不影响ssl的正常使用。

Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about EFF and
our work to encrypt the web, protect its users and defend digital rights.
-------------------------------------------------------------------------------
(Y)es/(N)o: Y

接下来就是系统会自动安装并配置一些必要的软件,然后询问是开启全站ssl还是http和https共存,一般会选择开启全站ssl。

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
-------------------------------------------------------------------------------
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
-------------------------------------------------------------------------------
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2

后面就会提醒你已经成功完成ssl安装和配置,但是如果没有自动找到对应的域名,这里需要手动输入你的域名。

Congratulations! You have successfully enabled https://pa.ci
You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=pa.ci

看到提示就表示已经完成了,这时候会在浏览器上出现一个表示ssl的绿色锁。
ssl
3.SSL续期方法
Let's Encrypt的SSL证书有效期只有90天,这意味着每三个月就要续期一次。续期只需要直接去重新运行一次命令就可以了,不需要额外的操作。

./letsencrypt-auto renew

标签: 教程, linux

添加新评论