<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>LetsEncrypt &#8211; 記下來</title>
	<atom:link href="https://noter.tw/tag/letsencrypt/feed/" rel="self" type="application/rss+xml" />
	<link>https://noter.tw</link>
	<description>一路上踩到的坑、遇到的問題，一點一滴記下來，希望能幫助到需要的人~</description>
	<lastBuildDate>Tue, 24 Oct 2023 00:32:39 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.6.3</generator>

<image>
	<url>https://noter.tw/wp-content/uploads/cropped-old-1130742_1920-1-32x32.jpg</url>
	<title>LetsEncrypt &#8211; 記下來</title>
	<link>https://noter.tw</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Certbot 申請 SSL certificate 錯誤問題</title>
		<link>https://noter.tw/8596/certbot-error/</link>
					<comments>https://noter.tw/8596/certbot-error/#respond</comments>
		
		<dc:creator><![CDATA[黃小蛙]]></dc:creator>
		<pubDate>Mon, 21 Jun 2021 15:36:28 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Web Server]]></category>
		<category><![CDATA[LetsEncrypt]]></category>
		<category><![CDATA[certbot]]></category>
		<category><![CDATA[certonly]]></category>
		<category><![CDATA[--dry-run]]></category>
		<category><![CDATA[The client lacks sufficient authorization]]></category>
		<category><![CDATA[Failed authorization procedure]]></category>
		<category><![CDATA[https]]></category>
		<category><![CDATA[--webroot]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Invalid response from]]></category>
		<category><![CDATA[certificate]]></category>
		<category><![CDATA[.well-known]]></category>
		<category><![CDATA[ssl]]></category>
		<category><![CDATA[acme-challenge]]></category>
		<category><![CDATA[SSL For Free]]></category>
		<guid isPermaLink="false">https://noter.tw/?p=8596</guid>

					<description><![CDATA[<p>今天幫好友處理 Certbot 的問題，這伺服器上已經申請過一個，這次要申請另一個域名，卻怎麼樣都會出現「The client lacks sufficient authorization」的錯誤，試&#46;&#46;&#46;</p>
<p>這篇文章 <a rel="nofollow" href="https://noter.tw/8596/certbot-error/" data-wpel-link="internal">Certbot 申請 SSL certificate 錯誤問題</a> 最早出現於 <a rel="nofollow" href="https://noter.tw" data-wpel-link="internal">記下來</a>。</p>
]]></description>
										<content:encoded><![CDATA[
<p>今天幫好友處理 Certbot 的問題，這伺服器上已經申請過一個，這次要申請另一個域名，卻怎麼樣都會出現「The client lacks sufficient authorization」的錯誤，試了一些時間總算完成。</p>



<span id="more-8596"></span>



<p>Certbot 真的是個方便的東西，記得很久以前小蛙架部落格剛要轉 https 的時候，還要去 <a href="https://www.sslforfree.com/" target="_blank" rel="noreferrer noopener nofollow external" data-wpel-link="external" class="wpel-icon-right">SSL for Free 網站<span class="wpel-icon wpel-image wpel-icon-6"></span></a>手動申請及安裝(可參考<a href="https://noter.tw/?s=ssl+for+free" target="_blank" rel="noreferrer noopener" data-wpel-link="internal">這邊</a>)，SSL for Free 的好處是申請 SSL 完全免費，但是有一個缺點是每三個月必須自己手動去更新(renew)，小蛙用了一段時間後發現，原來有 Certbot 這麼方便又好用的東西，之後有機會再來介紹這個，今天這篇只是要記錄使用 certbot 錯誤的解決方法。</p>



<p>是這樣的，在 Ubuntu 可以直接透過 certbot 申請 SSL 憑證，也包含了自動更新的功能，但是小蛙要申請一個新的網域的時候，卻發生了下列錯誤</p>



<pre class="wp-block-preformatted withcode">root@lc:/home/sysadm# certbot certonly --apache
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Which names would you like to activate HTTPS for?
 
1: mydomain.com
 
Select the appropriate numbers separated by commas and/or spaces, or leave input blank to select all options shown (Enter 'c' to cancel): 1

Obtaining a new certificate
Performing the following challenges:
http-01 challenge for mydomain.com
Waiting for verification…
Cleaning up challenges
Failed authorization procedure. mydomain.com (http-01): urn:ietf:params:acme:error:unauthorized :: The client lacks sufficient authorization :: Invalid response from http://mydomain.com/.well-known/acme-challenge/xxxxxx [xxx.xxx.xxx.xxx]: "\n\n404 Not Found\n\n Not Found \n&lt;p"
 IMPORTANT NOTES:
 The following errors were reported by the server:
 Domain: mydomain.com
 Type:   unauthorized
 Detail: Invalid response from
 http://mydomain.com/.well-known/acme-challenge/xxxx
 [xxx.xxx.xxx.xxx]: "\n\n404 Not Found\n\n Not Found \n&lt;p"

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.
Your account credentials have been saved in your Certbot configuration directory at /etc/letsencrypt. You should make a secure backup of this folder now. This configuration directory will also contain certificates and private keys obtained by Certbot so making regular backups of this folder is ideal. </pre>



<p>裡面看到幾個關鍵「Failed authorization procedure」、「unauthorized」、「Invalid response from」、「The client lacks sufficient authorization」</p>



<p>第一直覺是檔案連不到，但直接連 http://mydomain.com/.well-known/acme-challenge/xxxxxx 又沒有問題，看到朋友的主機有一堆奇怪的 site 設定檔，先清一清看看，嗯 ~ 好，沒有反應，錯誤還是存在。</p>



<p>一直發生上面的錯誤，不斷測試不斷重試，結果得到下面的錯誤 &#8230; (嗚嗚嗚)</p>



<pre class="wp-block-preformatted withcode">root@lc:/etc/apache2/sites-enabled# certbot --apache

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Which names would you like to activate HTTPS for?
 
 1: mydomain.com
 
Select the appropriate numbers separated by commas and/or spaces, or leave input blank to select all options shown (Enter 'c' to cancel): 1

Obtaining a new certificate
An unexpected error occurred:
  There were too many requests of a given type :: Error creating new order :: too many failed authorizations recently: see https://letsencrypt.org/docs/rate-limits/
Please see the logfiles in /var/log/letsencrypt for more details.</pre>



<p>進去錯誤訊息給的<a href="https://letsencrypt.org/zh-tw/docs/rate-limits/" target="_blank" rel="noreferrer noopener nofollow external" data-wpel-link="external" class="wpel-icon-right">連結<span class="wpel-icon wpel-image wpel-icon-6"></span></a>後，裡面有一段話寫著「我們還有<strong>網域驗證失敗</strong>限制，對於每個帳號每域名每小時 5 次的限制。在<a href="https://letsencrypt.org/zh-tw/docs/staging-environment/" target="_blank" rel="noreferrer noopener nofollow external" data-wpel-link="external" class="wpel-icon-right">測試環境<span class="wpel-icon wpel-image wpel-icon-6"></span></a>中並沒有那麼嚴格的限制，因此你可以使用測試環境來針對連線問題除錯。」</p>



<p class="withcode">額外得知原來加了<code>--dry-run</code>就是測試環境，只會用來測試並不會真正儲存申請的憑證，而且限制比較沒那麼嚴格，如果是要測試為什麼申請失敗只要加上<code>--dry-run</code>，確定都沒有問題後才透過正式環境申請。小蛙這邊超過了每小時五次的限制，只能等到先用<code>--dry-run</code>來測試，等 unban 之後再到正式環境申請了。</p>



<p>經過重重困難後，決定一個參數一個參數試試看，於是試出了</p>



<pre class="wp-block-preformatted withcode">root@lc:/var/www/html# certbot certonly --webroot -w /var/www/html/ -d mydomain.com
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator webroot, Installer None
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for mydomain.com
Using the webroot path /var/www/html for all unmatched domains.
Waiting for verification…
Cleaning up challenges

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



<p class="withcode">終於，加上了<code>--webroot -w /var/www/html/</code>之後就成功了 ~ 看起來可能是<code>.well-known/acme-challenge/xxxxxxx</code>的預設路徑不知道為什麼不在目前使用的目錄，導致驗證的時候會抓不到產生的驗證檔案而噴錯，加入該設定之後就完成了，這篇文章留給有需要的朋友 ~</p>



<p><strong>網站架設系列文章：</strong></p>



<ul class="my-li bg-darkblue wp-block-list"><li><a href="https://noter.tw/10151/%e7%9b%a4%e9%bb%9e%e9%82%a3%e4%ba%9b%e6%9b%be%e7%b6%93%e9%99%aa%e4%bc%b4%e9%81%8e%e5%b0%8f%e8%9b%99%e7%9a%84-vps-%e8%99%9b%e6%93%ac%e4%b8%bb%e6%a9%9f/" data-wpel-link="internal">盤點那些曾經陪伴過小蛙的 VPS 虛擬主機</a></li><li><a href="https://noter.tw/176/%e5%a6%82%e4%bd%95%e6%8c%91%e9%81%b8-vps-%e6%9c%80%e5%88%92%e7%ae%97%e7%9a%84%e8%b2%b7%e6%b3%95/" data-wpel-link="internal">如何挑選 VPS + 最划算的買法</a></li><li><a href="https://noter.tw/406/%E6%89%8B%E6%8A%8A%E6%89%8B%E6%95%99%E4%BD%A0%E5%A6%82%E4%BD%95%E8%B3%BC%E8%B2%B7-vps/" data-wpel-link="internal">手把手教你如何購買 VPS</a></li><li><a href="https://noter.tw/4463/第一次買-kvm-虛擬主機/" data-wpel-link="internal">第一次買 KVM 虛擬主機</a></li><li><a href="https://noter.tw/4242/%e8%a1%80%e7%9a%84%e6%95%99%e8%a8%93-hiformance-%e8%b7%91%e8%b7%af%e4%ba%86/" data-wpel-link="internal">血的教訓 &#8211; HiFormance 跑路了 &#8230;</a></li><li><a href="https://noter.tw/196/%e7%82%ba%e8%87%aa%e5%b7%b1%e7%94%b3%e8%ab%8b%e4%b8%80%e5%80%8b%e5%9f%9f%e5%90%8d-hinet-%e7%82%ba%e4%be%8b/" data-wpel-link="internal">為自己申請一個域名 – HiNet 為例</a></li><li><a href="https://noter.tw/117/cloudflare-%E8%B6%85%E5%BC%B7%E5%A4%A7%E7%9A%84%E5%85%8D%E8%B2%BB-cdn/" data-wpel-link="internal">Cloudflare – 超強大的免費 CDN (?)</a></li><li><a href="https://noter.tw/195/%e4%bd%bf%e7%94%a8-cloudflare-%e4%bb%a3%e7%ae%a1%e4%bd%a0%e7%9a%84%e5%9f%9f%e5%90%8d/" data-wpel-link="internal">使用 Cloudflare 代管你的域名</a></li><li><a href="https://noter.tw/396/ubuntu-16-04-設定環境語言編碼，讓中文可以正常顯示/" data-wpel-link="internal">Ubuntu 16.04 設定環境語言編碼，讓中文可以正常顯示</a></li><li><a href="https://noter.tw/255/ubuntu-16-04-%e5%ae%89%e8%a3%9d-fail2ban/" data-wpel-link="internal">Ubuntu 16.04 安裝 fail2ban</a></li><li><a href="https://noter.tw/436/%E4%B8%80%E5%80%8B%E8%85%B3%E6%9C%AC%E6%AF%8F%E5%A4%A9%E8%87%AA%E5%8B%95%E5%82%99%E4%BB%BD/" data-wpel-link="internal">一個腳本每天自動備份</a></li><li><a href="https://noter.tw/32/linux-tar-%E5%AE%8C%E6%95%B4%E5%82%99%E4%BB%BD%E3%80%81%E5%A2%9E%E9%87%8F%E5%82%99%E4%BB%BD%E5%8F%8A%E5%B7%AE%E7%95%B0%E5%82%99%E4%BB%BD%E6%AF%94%E8%BC%83/" data-wpel-link="internal">Linux tar 完整備份、增量備份及差異備份比較</a></li><li><a href="https://noter.tw/3704/nginx-ssl-certificate-%E8%AE%93-http-%E8%AE%8A%E8%BA%AB%E6%88%90%E7%82%BA-https/" data-wpel-link="internal">nginx + SSL Certificate – 讓 http 變身成為 https</a></li><li><a href="https://noter.tw/3695/ssl-for-free-%E5%85%8D%E8%B2%BB%E5%8F%88%E6%9C%89%E7%B6%A0%E8%89%B2%E9%8E%96%E9%A0%AD%E7%9A%84-ssl-certificates/" data-wpel-link="internal">SSL For Free – 免費又有綠色鎖頭的 SSL Certificates</a></li><li><a href="https://noter.tw/8596/certbot-error/" data-wpel-link="internal">Certbot 申請 SSL certificate 錯誤問題</a></li><li><a href="https://noter.tw/9107/certbot-error-acmev1-is-deprecated/" data-wpel-link="internal">Certbot 錯誤：ACMEv1 is deprecated and you can …</a></li><li><a href="https://noter.tw/5967/ubuntu-18-04-%e5%ae%89%e8%a3%9d-awstats-%e4%be%86%e7%b5%b1%e8%a8%88%e7%b6%b2%e7%ab%99%e6%b5%81%e9%87%8f/" data-wpel-link="internal">Ubuntu 18.04 安裝 AWStats 來統計網站流量</a></li><li><a href="https://noter.tw/9287/pchome-%e8%b2%b7%e7%b6%b2%e5%9d%80%e7%ba%8c%e7%b4%84%e6%b5%81%e7%a8%8b/" data-wpel-link="internal">PCHome 買網址續約流程</a></li></ul>
<p>這篇文章 <a rel="nofollow" href="https://noter.tw/8596/certbot-error/" data-wpel-link="internal">Certbot 申請 SSL certificate 錯誤問題</a> 最早出現於 <a rel="nofollow" href="https://noter.tw" data-wpel-link="internal">記下來</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://noter.tw/8596/certbot-error/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Ubuntu 取消 Apache 2.4 的 TLSv1.0 教學</title>
		<link>https://noter.tw/4812/ubuntu-18-04-%e7%92%b0%e5%a2%83%e4%b8%8b%e5%8f%96%e6%b6%88-apache-2-4-%e7%9a%84-tlsv1-0-%e6%95%99%e5%ad%b8/</link>
					<comments>https://noter.tw/4812/ubuntu-18-04-%e7%92%b0%e5%a2%83%e4%b8%8b%e5%8f%96%e6%b6%88-apache-2-4-%e7%9a%84-tlsv1-0-%e6%95%99%e5%ad%b8/#respond</comments>
		
		<dc:creator><![CDATA[黃小蛙]]></dc:creator>
		<pubDate>Fri, 03 May 2019 16:35:48 +0000</pubDate>
				<category><![CDATA[Web Server]]></category>
		<category><![CDATA[關閉 SSLv3]]></category>
		<category><![CDATA[只允許 TLSv1.2]]></category>
		<category><![CDATA[SSLProtocol 設定]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[ssl]]></category>
		<category><![CDATA[TLSv1.0]]></category>
		<category><![CDATA[LetsEncrypt]]></category>
		<category><![CDATA[2019]]></category>
		<category><![CDATA[關閉 TLSv1]]></category>
		<guid isPermaLink="false">https://noter.tw/?p=4812</guid>

					<description><![CDATA[<p>突然接到一個求救，資安掃描的時候掃出 TLSv1.0 應該要關閉的漏洞，就開始 Google 要怎麼設定，Apache 小蛙不熟，通常都是問題來一個找一個解一個，來兩個找兩個解一雙 ~ 這篇記錄留給有&#46;&#46;&#46;</p>
<p>這篇文章 <a rel="nofollow" href="https://noter.tw/4812/ubuntu-18-04-%e7%92%b0%e5%a2%83%e4%b8%8b%e5%8f%96%e6%b6%88-apache-2-4-%e7%9a%84-tlsv1-0-%e6%95%99%e5%ad%b8/" data-wpel-link="internal">Ubuntu 取消 Apache 2.4 的 TLSv1.0 教學</a> 最早出現於 <a rel="nofollow" href="https://noter.tw" data-wpel-link="internal">記下來</a>。</p>
]]></description>
										<content:encoded><![CDATA[
<p>突然接到一個求救，資安掃描的時候掃出 TLSv1.0 應該要關閉的漏洞，就開始 Google 要怎麼設定，Apache 小蛙不熟，通常都是問題來一個找一個解一個，來兩個找兩個解一雙 ~ 這篇記錄留給有需要的人。</p>



<span id="more-4812"></span>



<p>這問題直接丟 Google 會有很多很多一拖拉庫的解法，不過有些應該是 CentOS 或是其他版本的，小蛙看 Ubuntu 18.04 + Apache 2.4 的路徑在 /etc/apache2/，跟網路上很多教學裡提到的 /etc/httpd/ 不一樣，就 ~ 都試試看吧。</p>



<p>終於看到一篇好像不錯 <a href="https://www.cloudibee.com/disabling-tls-apache/" target="_blank" rel="noreferrer noopener nofollow external" data-wpel-link="external" class="wpel-icon-right">Disabling TLS 1.0 on Apache web servers<span class="wpel-icon wpel-image wpel-icon-6"></span></a>，嗯嗯，路徑不同，不過既然知道要修改的屬性名稱叫做「SSLProtocol」，那就到小蛙的目錄 /etc/apache2/ 來搜尋一下</p>



<pre class="wp-block-preformatted wp-block-syntaxhighlighter-code">$ cd /etc/apache2/
$ grep -ir "SSLProtocol" *
mods-available/ssl.conf:        SSLProtocol all -SSLv3</pre>



<p>Bingo! 找到在模組資料夾中的 ssl.conf，動手改掉他吧！小蛙收到的需求是把 1.0 跟 1.1 關閉，保留 1.2 即可，因此把上面的 <code>SSLProtocol all -SSLv3</code> 改成 <code>SSLProtocol TLSv1.2</code>，改好之後 sudo service apache2 restart，立馬到 <a href="https://www.sslshopper.com/ssl-checker.html" target="_blank" rel="noreferrer noopener nofollow external" data-wpel-link="external" class="wpel-icon-right">SSL Checker<span class="wpel-icon wpel-image wpel-icon-6"></span></a> 測試看看，結果 &#8230; 竟然沒生效 @@</p>



<p>左查右查，會不會是上面的網站 cache 呢？下指令查查看</p>



<pre class="wp-block-preformatted wp-block-syntaxhighlighter-code">$ nmap --script ssl-enum-ciphers -p 443 ip或domain | grep TLSv
|   TLSv1.0:
|   TLSv1.1:
|   TLSv1.2:</pre>



<p>我的天啊 ~ 真的沒生效 &#8230; (如果沒有安裝的話可以先 apt-get install nmap 來安裝這個套件)，查了很多 stackoverflow 終於找到這篇 <a href="https://stackoverflow.com/a/55282453/1227342" target="_blank" rel="noreferrer noopener nofollow external" data-wpel-link="external" class="wpel-icon-right">Disabling TLS 1.0 in Apache 2.4<span class="wpel-icon wpel-image wpel-icon-6"></span></a>，原來設定有成功，只是因為小蛙使用了 letsencrypt 的免費 SSL，造成 Apache 載入 SSL 設定的時候，會被較後面載入的 letsencrypt 設定檔蓋掉，因此前面的 ssl.conf 才會設定了但沒有效果。把剛剛上面的設定檔設定到 /etc/letsencrypt/options-ssl-apache.conf 看看吧！</p>



<pre class="wp-block-preformatted wp-block-syntaxhighlighter-code">$ nmap --script ssl-enum-ciphers -p 443 ip或domain | grep TLSv
|   TLSv1.2:</pre>



<p>打完收工，太感謝 stackoverflow 的那個答案了，真的好想幫他按讚，可惜小蛙的積分不夠 &gt;..&lt;</p>
<p>這篇文章 <a rel="nofollow" href="https://noter.tw/4812/ubuntu-18-04-%e7%92%b0%e5%a2%83%e4%b8%8b%e5%8f%96%e6%b6%88-apache-2-4-%e7%9a%84-tlsv1-0-%e6%95%99%e5%ad%b8/" data-wpel-link="internal">Ubuntu 取消 Apache 2.4 的 TLSv1.0 教學</a> 最早出現於 <a rel="nofollow" href="https://noter.tw" data-wpel-link="internal">記下來</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://noter.tw/4812/ubuntu-18-04-%e7%92%b0%e5%a2%83%e4%b8%8b%e5%8f%96%e6%b6%88-apache-2-4-%e7%9a%84-tlsv1-0-%e6%95%99%e5%ad%b8/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
