简体   繁体   English

让我们在子域上加密SSL证书

[英]Let's encrypt SSL certificate on subdomain

I developed an application for a client which I host on a subdomain, now the problem is that I don't own the main domain/website. 我为托管在子域上的客户端开发了一个应用程序,现在的问题是我不拥有主域/网站。 They've added a DNS record to point to the IP on which I host that app. 他们添加了DNS记录以指向我托管该应用程序的IP。 Now I want to request a Free & automatic certificate from Let's Encrypt. 现在,我想从Let's Encrypt请求免费和自动证书。 But when I try the handshake it says 但是当我尝试握手时说

Getting challenge for subdomain.example.com from acme-server...
Error: http://subdomain.example.com/.well-known/acme-challenge/letsencrypt_**** is not reachable. Aborting the script.
dig output for subdomain.example.com:subdomain.example.com
Please make sure /.well-known alias is setup in WWW server.

Which makes sense cause I don't own that domain on my server. 这是有道理的,因为我在服务器上不拥有该域。 But if I try to generate it without the main domain I get: 但是,如果我尝试在没有主域的情况下生成它,则会得到:

You must include your main domain: example.com.

Cannot Execute Your Request

Details

Must include your domain example.com in the LetsEncrypt entries.

So I'm curious on how I can just set up a certificate without owning the main domain. 所以我很好奇我如何不拥有主域就可以设置证书。 I tried googling the issue but I couldn't find any relevant results. 我尝试搜寻该问题,但找不到任何相关结果。 Any help would be much appreciated. 任何帮助将非常感激。

First 第一

You don't need to own the domain, you just need to be able to copy a file to the location serving that domain. 您不需要拥有该域,只需要能够将文件复制到该域的服务位置即可。 (You're all set there it sounds like) (您都设置在那里,听起来像)

Second 第二

What tool are you using? 您正在使用什么工具? The error message you gave makes me think the client is misconfigured. 您给出的错误消息使我认为客户端配置错误。 The challenge name is usually something like https://example.com/.well-known/acme-challenge/jQqx6qlM8u3wpi88N6lwvFd7SA07oK468mB1x4YIk1g . 质询名称通常类似于https://example.com/.well-known/acme-challenge/jQqx6qlM8u3wpi88N6lwvFd7SA07oK468mB1x4YIk1g Compare that to your error: 将此与您的错误进行比较:

    Error: http://example.com/.well-known/acme-challenge/letsencrypt_example.com is not reachable. Aborting the script.

Third 第三

I'm the author of Greenlock , which is compatible with Let's Encrypt. 我是Greenlock的作者,它与Let's Encrypt兼容。 I'm confident that it will work for you. 我相信它将为您服务。

Install 安装

# Feel free to read the source first
curl -fsS https://get.greenlock.app/ | bash

Usage with existing webserver : 现有网络服务器的用法

Let's say that: 可以这样说:

  • You're using Apache or Nginx. 您正在使用Apache或Nginx。
  • You confirm that ping example.com gives the IP of your server 您确认ping example.com提供了服务器的IP
  • You're exposing http on port 80 (otherwise verification will fail) 您在端口80上暴露了HTTP(否则验证将失败)
  • Your website is located in /srv/www/example.com 您的网站位于/srv/www/example.com
  • Your email is jon@example.com (must be a real email address) 您的电子邮件为jon@example.com (必须是真实的电子邮件地址)
  • You want to store your certificate as /etc/acme/live/example.com/fullchain.pem 您要将证书存储为/etc/acme/live/example.com/fullchain.pem

This is what the command would look like: 该命令将如下所示:

sudo greenlock certonly --webroot \
  --acme-version draft-11 --acme-url https://acme-v02.api.letsencrypt.org/directory \
  --agree-tos --email jon@example.com --domains example.com \
  --community-member \
  --root /srv/www/example.com \
  --config-dir /etc/acme

If that doesn't work on the first try then change out --acme-url https://acme-v02.api.letsencrypt.org/directory for --acme-url https://acme-staging-v02.api.letsencrypt.org/directory while you debug. 如果这在第一次尝试中--acme-url https://acme-v02.api.letsencrypt.org/directory--acme-url https://acme-staging-v02.api.letsencrypt.org/directory --acme-url https://acme-v02.api.letsencrypt.org/directory --acme-url https://acme-staging-v02.api.letsencrypt.org/directory更改为调试时的--acme-url https://acme-staging-v02.api.letsencrypt.org/directory Otherwise your server could become blocked from Let's Encrypt for too many bad requests. 否则,对于太多错误请求,您的服务器可能会被阻止进行加密。 Just know that you'll have to delete the certificates from the staging environment and retry with the production url since the tool cannot tell which certificates are "production" and which ones are "testing". 只是知道您必须从登台环境中删除证书,然后使用生产url重试,因为该工具无法确定哪些证书是“生产”,哪些证书是“测试”。

The --community-member flag is optional, but will provide me with analytics and allow me to contact you about important or mandatory changes as well as other relevant updates. --community-member标志是可选的,但它将为我提供分析,并允许我与您联系以进行重要或强制性更改以及其他相关更新。

After you get the success message you can then use those certificates in your webserver config and restart it. 获得成功消息后,您可以在Web服务器配置中使用这些证书并重新启动它。

That will work as a cron job as well. 这也将作为一项日常工作。 You could run it daily and it will only renew the certificate after about 75 days. 您可以每天运行一次,它将仅在大约75天后续签证书。 You could also put a cron job to send the "update configuration" signal to your webserver (normally HUP or USR1) every few days to cause it to start using the new certificates without even restarting (...or just have it restart). 您还可以放置一个cron作业,每隔几天将“更新配置”信号发送到您的Web服务器(通常为HUP或USR1),以使其开始使用新证书,而无需重新启动(...或者只是重新启动)。

Usage without a web server 无需网络服务器即可使用

If you just want to quickly test without even having a webserver running, this will do it for you: 如果您只是想快速测试甚至不运行网络服务器,这将为您做到:

sudo greenlock certonly --standalone \
  --acme-version draft-11 --acme-url https://acme-v02.api.letsencrypt.org/directory \
  --agree-tos --email jon@example.com --domains example.com \
  --community-member \
  --config-dir /etc/acme/

That runs expecting that you DO NOT have a webserver running on port 80, as it will start one temporarily just for the purpose of the certificate. 希望您没有在端口80上运行的Web服务器,因为它将仅出于证书目的而临时启动一个。

sudo is required for using port 80 and for writing to root and httpd-owned directories (like /etc and /srv/www). 使用端口80以及写入根目录和httpd拥有的目录(例如/ etc和/ srv / www)时,需要sudo You can run the command as your webserver's user instead if that has the correct permissions. 如果具有正确的权限,则可以以Web服务器的用户身份运行命令。

Use Greenlock as your webserver 使用Greenlock 作为您的网络服务器

We're working on an option to bypass the middleman altogether and simply use greenlock as your webserver, which would probably work great for simple vhosting like it sounds like you're doing. 我们正在研究一个完全绕开中间人的选项,只是将greenlock用作您的Web服务器,这对于听起来像您正在做的简单虚拟化可能非常有用。 Let me know if that's interesting to you and I'll make sure to update you about it. 让我知道这是否对您有趣,我将确保向您更新。

Fourth 第四

Let's Encrypt also has an official client called certbot which will likely work just as well, perhaps better, but back in the early days it was easier for me to build my own than to use theirs due to issues which they have long since fixed. Let's Encrypt还拥有一个称为certbot的官方客户端,该客户端可能会同样工作,也许会更好,但是在早期,由于他们早已解决了一些问题,对于我自己来说,构建它们自己比使用它们更容易。

Whats important is the sub domains A record. 重要的是子域A记录。 It should be the IP Address of from where you are trying to request the sub domains certificate. 它应该是您尝试从中请求子域证书的IP地址。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM