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/主機

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

元:我修復了你的格式並恢復了 # 這實際上是 /etc/hosts 語法的必要部分;請點擊?編輯視窗中的圖標並閱讀“代碼”的幫助(也許還有其他)

請注意,這與雖然它們www.{something}不同{something}可能映射到相同的位址和主機。

從日誌中可以明顯看出,您實際上正在請求一個證書,digierp.com該證書在公共 DNS 中映射到 110.40.197.199,並且www.digierp.com哪個 certbot 也應該請求您顯示的配置,但顯然沒有嘗試過,因為第一次挑戰失敗了。

若要使用 http-01 質詢從 LetsEncrypt 取得證書,您的伺服器必須可以透過公用 DNS 決定的位址從公共 Internet 存取。 LetsEncrypt 無法查看您本地的內容/etc/hosts,即使可以,它也不會信任它,因為來自 LE 等公共 CA 的憑證的全部意義在於世界各地的其他人可以信任您的伺服器的身份。

如果你控制這個網域的 DNS,你沒有說,你的貼文也沒有顯示,你可以使用 dns-01 挑戰取得本機伺服器名稱的 LE 憑證;根據您使用的 DNS 提供者,可能有一個插件,或者您可能需要手動執行此操作。然後,該憑證可以與[www.]digierp.com使用 /etc/hosts 或類似內容本地對應到 127.0.0.1 或另一個本機位址的用戶端一起使用。


要從 LE 或大多數公共 CA 取得證書,您必須「控制」公開註冊的網域。實際上,這意味著要么付費,要么讓某人(付費的人)向您提供;例如,如果您是學校的工作人員,他們可能會在其網域下為您提供子網域。您可以從一些公共CA 獲得IP 位址的證書,但只能是公共可路由且靜態分配的證書,絕對不是用於本地使用的位址,例如環回(127.0.0.1 或::1)、rfc1918 或fe80 :/ 16.

在公共CA 之外,如果您不在像一些大型企業和政府機構那樣運行“本地”CA 的組織中,您可以像Falcon 指出的那樣簡單地生成自簽名證書,或者稍微複雜一點地設置您自己的憑證私人的、個人的 CA(只有你自己信任,沒有其他人信任)。請參閱我在多個堆疊中關於此主題的 Q 連結列表,網址為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 要求 Letscrypt 使用 ACME 協定透過網際網路驗證您對網域的控制,然後向您提供憑證。當您嘗試僅在環回上執行伺服器時,您不能使用它。

若要使用 LetsEncrypt,請將 DNS(不是您的主機檔案)設定為指向您正在執行網站的伺服器。如果需要進行本機測試,請使用其他工具;有些人會頒發自簽名憑證並將其添加到他們的信任儲存中(或忽略 TLS 警告)。

相關內容