本教程将讲解如何使用Certbot(一款自动化证书管理和移除工具)在Linux服务器上自动获取证书并进行后续部署。本教程主要针对Apache服务器,但Certbot也适用于nginx、Haproxy和Plesk服务器。Certbot采用开放软件许可证,因此可以免费使用。
准备获取证书
为了实现自动证书获取和部署,需要首先联系我们的技术支持,并为每个客户遵循简单的个人程序。
第一步是授权您和您想要保护的域名。这需要与负责此工作的Gworg支持团队合作完成。
授权成功后,我们将在证书颁发机构创建一个唯一的ACME目录URL。您的ACME客户端(本例中为Certbot)将使用此URL获取证书。ACME目录URL对于每个客户和产品都是唯一的。无法为多个客户使用同一个URL。
ACME目录URL是您唯一可以使用的产品。NelzepoužítjednoURL是这样的。
在服务器上准备Certbot:
在您的服务器上安装Certbot。我们建议您使用适合您的Web服务器类型的模块。模块可以让您更轻松地选择部署证书的目标站点,并且可以直接与服务器配置配合使用(从而简化证书安装)。
注意:请访问Certbot官方主页并按照分步说明进行操作。
颁发和安装证书
使用终端,通过输入以下命令来请求证书:
sudo certbot --apache --register-unsafely-without-email --server “Vaše ACME Directory URL” -d www.domainname.cz -d domainname.cz
该命令以这样的方式工作:
Certbot–执行Certbot
--apache–选择安装证书的Apache插件。
--register-unsafely-without-email–允许跳过ACME帐户创建。
--server–通过ACME目录URL选择用于满足您的请求的ACME服务器
-d–您希望颁发证书的完整域名。如果您不使用此参数,Cerbot将根据vhost配置提示您确认要包含在请求中的域名。
输入命令后,会提示你是否要在域上启用强制重定向到HTTPS协议:
Output 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):
输入号码并按ENTER确认。您的配置将被设置,并在Web服务器重启后加载。之后,您将收到通知,告知您的请求已成功完成,并了解您的证书位于何处:
Output IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at /etc/letsencrypt/live/example.com/fullchain.pem. Your cert will expire on 2017-10-23. To obtain a new or tweaked version of this certificate in the future, simply run certbot again with the "certonly" option. To non-interactively renew *all* of your certificates, run "certbot renew" - Your account credentials have been saved in your Certbot configuration directory at /etc/letsencrypt. You should make a secure backup of this folder now. This configuration directory will also contain certificates and private keys obtained by Certbot so making regular backups of this folder is ideal. - If you like Certbot, please consider supporting our work by: Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate Donating to EFF: https://eff.org/donate-le
Certbot安装了必要的中级证书,您可以使用我们的在线工具验证是否安装正确。
一般说明
有几条规则限制证书颁发自动化,请注意以下几点:
目前不支持DV证书
颁发证书前需要获得公司和域名的授权
需要在域上进行预防。它包括两个步骤:
1.DCV,域验证(电子邮件、DNS、TXT)
2.已验证域名分配给已验证的公司,并可供该公司使用
ACME目录URL对于每个产品和公司都是唯一的,因此您可能需要更多URL
本教程涵盖典型场景,请考虑您的个人服务器设置。