如何在Heroku上安装LetsEncrypt SSL证书

bln*_*lnc 13 ruby-on-rails heroku ruby-on-rails-4 lets-encrypt

由于Heroku是只读的并且不允许sudo,我需要做什么才能在我们的应用程序的服务器上安装LetsEncrypt.org证书?

如果我已经确定了config.force_ssl = true那件事吗?

gro*_*der 5

我在这里的第一个答案中阅读了博客文章,但我不想使用ACME网址和逻辑来污染我的代码库。所以我做了类似的事情,但是使用了DNS域验证...

使用certbot,将DNS指定为您的首选挑战:

sudo certbot certonly --manual --preferred-challenges dns
Run Code Online (Sandbox Code Playgroud)

在几次提示后,certbot会告诉您使用DNS TXT记录来验证您的域:

Please deploy a DNS TXT record under the name
_acme-challenge.www.codesy.io with the following value:

CxYdvM...5WvXR0

Once this is deployed,
Press ENTER to continue
Run Code Online (Sandbox Code Playgroud)

您的域名注册商可能有自己的文档来部署TXT记录。这样做,然后返回certbot并按Enter-让我们的Encrypt将检查TXT记录,对证书进行签名,然后certbot将其保存以供您上载到heroku。

有关更多详细信息,请参见我自己的博客文章


这是两个bash函数,可用于为您自动执行该过程

function makessl {
    sudo certbot certonly --manual --rsa-key-size 4096 --preferred-challenges dns -d ${1}
    sudo heroku certs:add --type=sni /etc/letsencrypt/live/${1}/fullchain.pem /etc/letsencrypt/live/${1}/privkey.pem
}

function renewssl {
    sudo certbot certonly --manual --rsa-key-size 4096 --preferred-challenges dns -d ${1}
    sudo heroku certs:update /etc/letsencrypt/live/${1}/fullchain.pem /etc/letsencrypt/live/${1}/privkey.pem
}
Run Code Online (Sandbox Code Playgroud)

他们为域名辩护,只要您在自己的内部运行它们,heroku app folder就不必指定域名--app NAME

例: makessl www.domain.com

例: renewssl www.domain.com


结合这是@Eric的答案,您很好:

heroku certs:auto:enable


Eri*_*ric 5

仅供参考,如果您运行付费测功机,Heroku 现在可以提供自动化证书管理和 Let's Encrypt。您可以通过以下方式启用它:

heroku certs:auto:enable
Run Code Online (Sandbox Code Playgroud)

更多信息:

https://devcenter.heroku.com/articles/automated-certificate-management