APACHE CERTBOT 错误

APACHE CERTBOT 错误

我正在使用 certbot 在本地 apache 服务器上配置 https,但出现以下错误:

Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: www.example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): 
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for digierp.com
Enabled Apache rewrite module
Waiting for verification...
Challenge failed for domain digierp.com
http-01 challenge for digierp.com
Cleaning up challenges
Some challenges have failed.

IMPORTANT NOTES:
 - The following errors were reported by the server:

   Domain: www.example.com
   Type:   connection
   Detail: 110.40.19...: Fetching
   http://example.com/.well-known/acme-challenge/X3IbvKI9gbZu1.........:
   Connection refused

   To fix these errors, please make sure that your domain name was
   entered correctly and the DNS A/AAAA record(s) for that domain
   contain(s) the right IP address. Additionally, please check that
   your computer has a publicly routable IP address and that no
   firewalls are preventing the server from communicating with the
   client. If you're using the webroot plugin, you should also verify
   that you are serving files from the webroot path you provided.

这是我的 /etc/apache2/sites-available/exapmlee.conf 文件

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName examplee
    ServerAlias www.example.com
    DocumentRoot /var/www/examplee
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

如果我深入研究 example.com,我会得到这个

;; ANSWER SECTION:
example.com.        0   IN  A   127.0.0.1

/etc/hosts

127.0.0.1       localhost
127.0.1.1       digierp-Joy

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

127.0.0.1       example.com

系统在哪里获取这个 IP 110.40.19...?

对于上述错误有什么建议吗?

答案1

Meta:我修复了你的格式并恢复了#,这实际上是/etc/hosts语法的必要部分;请单击编辑窗口中的?图标并阅读“代码”的帮助(也可能阅读其他内容)

请注意,这www.{something}{something}尽管它们可能映射到相同的地址和主机。

从日志中可以明显看出,您实际上是在请求一个证书,digierp.com该证书在公共 DNS 中映射到 110.40.197.199,而且www.digierp.comcertbot 也应该请求您所展示的配置,但由于第一次挑战失败,显然没有尝试。

要使用 http-01 质询从 LetsEncrypt 获取证书,您的服务器必须能够通过公共 DNS 确定的地址从公共互联网访问。LetsEncrypt 无法看到您本地的内容/etc/hosts,即使可以看到也不会信任它,因为来自 LE 等公共 CA 的证书的全部意义在于世界各地的其他人可以信任您服务器的身份。

如果您可以控制此域的 DNS(您没有说,您的帖子也没有显示),您可以使用 dns-01 质询获取本地服务器名称的 LE 证书;根据您使用的 DNS 提供商,可能有一个插件,或者您可能需要手动执行。然后可以使用[www.]digierp.com/etc/hosts 或类似文件将该证书用于本地映射到 127.0.0.1 或其他本地地址的客户端。


要从 LE 或大多数公共 CA 获取证书,您必须“控制”一个公开注册的域名。实际上,这意味着要么付费,要么让某人(付费)为您提供该域名;例如,如果您是学校的教职员工,他们可能会为您提供其域下的子域。您可以从一些公共 CA 获取 IP 地址的证书,但只能是可公开路由和静态分配的 IP 地址,绝对不是用于本地使用的地址,如环回(127.0.0.1 或 ::1)、rfc1918 或 fe80:/16。

除了公共 CA 之外,如果您所在的组织没有运行“本地”CA,例如一些大型企业和政府机构,那么您可以像 Falcon 指出的那样简单地生成自签名证书,或者稍微复杂一点,设置您自己的私有 CA(只有您自己,其他人都不信任)。请参阅我在多个 Stacks 中关于此主题的问答链接列表,网址为https://stackoverflow.com/questions/69499225/how-to-solve-the-problem-of-self-signed-ssl-certificates-for-sites-intended-to-b

答案2

您是否正在尝试从 letsencrypt 获取证书www.example.com你不能这么做。这不是你的。

我看到你正在做几件不同的事情。你已向 certbot 请求证书www.example.com但您的问题其余部分是关于 example.com 的。这是两个不同的东西;www 根本没有暗示。不过,为两者获取证书是很常见的www.example.com和 example.com,其中 example.com 是您的域名

也许您的域名是 digierp.com?您在某些地方编辑了它,但在其他地方没有编辑。

除此之外,我认为您通常正确地使用了这些工具。但 letsencrypt 不是本地工具。Certbot 要求 letsencrypt 使用 ACME 协议通过互联网验证您对域的控制,然后向您提供证书。当您尝试仅在环回上运行服务器时,您无法使用它。

要使用 letsencrypt,请将 DNS(而不是您的主机文件)设置为指向您正在运行网站的服务器。如果您需要进行本地测试,请使用其他工具;有些人会颁发自签名证书并将其添加到他们的信任存储中(或忽略 TLS 警告)。

相关内容