LetsEncrypt Free SSL 通配符证书申请方法

LetsEncrypt Free SSL 通配符证书申请方法

通过官方推荐工具certbot申请

[TOC]

第一步

certbot-2 certonly -d *.lixuedong.com --manual --preferred-challenges dns --server https://acme-v02.api.letsencrypt.org/directory
  • certonly,表示安装模式,Certbot有安装模式和验证模式两种类型的插件。

  • --manual表示手动安装插件,Certbot有很多插件,不同的插件都可以申请证书,用户可以根据需要自行选择

  • -d为那些主机申请证书,如果是通配符,输入* .lixuedong.com(替换为你自己的域名)

  • --preferred-challenge dns,使用DNS方式校验域名所有权

    • 客户在申请Let's Encrypt证书的时候,需要校验域名的所有权,证明操作者有权利为该域名申请证书,目前支持三种验证方式:
      • dns-01:给域名添加一个DNS TXT记录。
      • http-01:在域名对应的Web服务器下放置一个HTTP着名的URL资源文件。
      • tls-sni-01:在域名对应的Web服务器下放置一个HTTPS着名的URL资源文件
    • 申请通配符证书,只能使用dns-01的方式
  • --server,让我们加密ACME v2版本使用的服务器不同于v1版本,需要显示指定

交互式命令行输出

Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
-------------------------------------------------------------------------------
(A)gree/(C)ancel: A
请阅读服务条款
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf。 你必须
同意以便在ACME服务器上注册
https://acme-v02.api.letsencrypt.org/directory
Plugins selected: Authenticator manual, Installer None
Starting new HTTPS connection (1): acme-v02.api.letsencrypt.org
Obtaining a new certificate
Performing the following challenges:
dns-01 challenge for lixuedong.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NOTE: The IP of this machine will be publicly logged as having requested this
certificate. If you're running certbot in manual mode on a machine that is not
your server, please ensure you're okay with that.

Are you OK with your IP being logged?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: y

选择的插件:Authenticator manual,Installer None
启动新的HTTPS连接(1):acme-v02.api.letsencrypt.org
获得新证书
执行以下挑战:
dix-01挑战lixuedong.com
注意:本机的IP将公开记录为已请求此项
证书。 如果您在非手动模式下以手动模式运行certbot
你的服务器,请确保你没事。

您的IP被记录了吗?
(Y)es /(N)o:y
(就是问你的域名有没有解析到公网IP)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please deploy a DNS TXT record under the name
_acme-challenge.lixuedong.com with the following value:

z55lrkHoxYaFoGsvUASE0WgaIifiP-iiVwac-JUd-94

Before continuing, verify the record is deployed.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Press Enter to Continue

配置解析记录

配置DNS TXT记录,校验域名所有权,在没有确认TXT记录生效之前不要回车执行。
截图

证书申请成功

Waiting for verification...
Resetting dropped connection: acme-v02.api.letsencrypt.org
Resetting dropped connection: acme-v02.api.letsencrypt.org
Cleaning up challenges
Resetting dropped connection: acme-v02.api.letsencrypt.org

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/lixuedong.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/lixuedong.com/privkey.pem
   Your cert will expire on 2019-04-23. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot
   again. To non-interactively renew *all* of your certificates, run
   "certbot renew"
 - 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


证书申请成功

保存在 /etc/letsencrypt/archive/lixuedong.com

手动安装证书

我用的是Apache服务器

进入Apache服务器安装目录

创建一个保存证书的目录

cd /usr/local/apache && mkdir cert

将证书从默认路径下复制过来

mv /etc/letsencrypt/archive/lixuedong.com/* /usr/local/apache/cert

修改配置文件

vim /usr/local/apache/conf/extra/http-ssl.conf
<VirtualHost 0.0.0.0:443>
        DocumentRoot "/home/www/htdocs"
        ServerName www.lixuedong.com
        SSLEngine on
        SSLCertificateFile cert/fullchain1.pem
        SSLCertificateKeyFile cert/privkey1.pem
        SSLCertificateChainFile cert/chain1.pem
</VirtualHost>

重启Apache服务器

/usr/local/apache/bin/apachectl stop && /usr/local/apache/bin/apachectl start

大功告成!

20190123144758.png

20190123144742.png

错误问题

certbot 执行报错

我遇到的是

Traceback (most recent call last):
  File "/usr/bin/certbot-2", line 9, in <module>
    load_entry_point('certbot==0.29.1', 'console_scripts', 'certbot')()
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 564, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2662, in load_entry_point
    return ep.load()
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2316, in load
    return self.resolve()
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2322, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python2.7/site-packages/certbot/main.py", line 23, in <module>
    from certbot import client
  File "/usr/lib/python2.7/site-packages/certbot/client.py", line 16, in <module>
    from acme import client as acme_client
  File "/usr/lib/python2.7/site-packages/acme/client.py", line 40, in <module>
    urllib3.contrib.pyopenssl.inject_into_urllib3()
AttributeError: 'module' object has no attribute 'pyopenssl'

解决办法

yum install certbot
pip install --upgrade --force-reinstall 'requests==2.6.0' urllib3
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 160,706评论 4 366
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 68,002评论 1 301
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 110,462评论 0 250
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 44,375评论 0 216
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,763评论 3 294
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,849评论 1 224
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 32,033评论 2 317
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,768评论 0 204
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,490评论 1 246
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,734评论 2 253
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,204评论 1 264
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,566评论 3 260
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,227评论 3 241
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,137评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,934评论 0 201
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,926评论 2 283
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,774评论 2 274

推荐阅读更多精彩内容

  • Swift1> Swift和OC的区别1.1> Swift没有地址/指针的概念1.2> 泛型1.3> 类型严谨 对...
    cosWriter阅读 11,039评论 1 32
  • 2017年10月5日完成 国画水墨山水画系列
    春城怡景阅读 217评论 1 8
  • 搞不懂为什么活着这么疲倦,更搞不懂我为什么这么贪生。
    若言喵喵阅读 188评论 1 2