Let's Encryptで無料SSL導入
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
]
開始行:
[[Linuxめも]]
#contents
GoogleがやたらとSSL対応を勧めてくるんですよ。~
やっぱり今後はSSL対応が必須になる時代が来そうです。
でもSSLって高いイメージがあるし、証明書の更新も面倒。~
今の時代無料でできねーかなと調べてみたらなんかできそうな...
[[Let's Encrypt:https://letsencrypt.jp/]] で無料でSSLが導...
証明書の発行・インストール・更新のプロセスを自動化できる...
制限があります。~
https://letsencrypt.org/docs/rate-limits/
制限についての説明はこちらが詳しいです。~
ありがとうございます。~
http://qiita.com/sawanoboly/items/8e3c57aa2e30fc58c4e3
参考
-https://def-4.com/lets-encrypt-multi-domains/
-https://def-4.com/letsencrypt-tls-sni-01-challenge-error/
-https://blog.apar.jp/linux/3619/
-http://qiita.com/tkykmw/items/9b6ba55bb2a6a5d90963
*certbotのインストールと自動更新設定 [#o133672c]
# yum install certbot
# yum install python2-certbot-apache
# certbot --apache -d example.com
# service httpd graceful
更新対象が無い場合はスキップされるので毎日実行しても大丈...
結果はメールで確認できるようにします。~
hookが必要かどうかは確認中。
# root
#5 9 * * * /usr/bin/certbot renew --post-hook "systemctl...
5 9 * * * /usr/bin/certbot renew 2>&1 | mail -s "Let's E...
※以下は古い内容です。
*クライアントソフトCertbotのインストール [#w457122c]
# wget https://dl.eff.org/certbot-auto
# chmod 700 certbot-auto
ヘルプは以下で確認できます。
# ./certbot-auto --help
以下を実行すると、自動的にyumが実行され、必要なパッケージ...
# ./certbot-auto
CentOS6.2ではyumにて python-pip-1.3.1-4.el6.noarch がダウ...
epelリポジトリを入れるとハマるみたいです。~
設定を書き換えます。
# vi /etc/yum.repos.d/epel.repo
#baseurl=http://download.fedoraproject.org/pub/epel/6/$b...
mirrorlist=https://mirrors.fedoraproject.org/metalink?re...
↓
baseurl=http://download.fedoraproject.org/pub/epel/6/$ba...
#mirrorlist=https://mirrors.fedoraproject.org/metalink?r...
CentOS5.5など古いOSは以下を参考にさせてもらえば利用が可能...
https://clouds.tokyo/blog/linux_lets_cent5/
*証明書の取得 [#ede60d3a]
同一サーバで別ドメインの証明書を取得する場合は、443ポート...
そのため開始前にWEBサーバを止めておきます。~
また、メールアドレスの入力と同意の設問はスキップされます。
# ./certbot-auto certonly
How would you like to authenticate with the ACME CA?
--------------------------------------------------------...
1: Place files in webroot directory (webroot)
2: Spin up a temporary webserver (standalone)
--------------------------------------------------------...
Select the appropriate number [1-2] then [enter] (press ...
2を入力~
※certbot-autoのバージョンが上がって順番が入れ替わっている...
Enter email address (used for urgent renewal and securit...
メールアドレスを入力
--------------------------------------------------------...
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.1.1-August-1-...
in order to register with the ACME server at
https://acme-v01.api.letsencrypt.org/directory
--------------------------------------------------------...
(A)gree/(C)ancel:
Aを入力
Please enter in your domain name(s) (comma and/or space ...
証明書を導入したいドメインをカンマもしくはスペース区切り...
成功すれば /etc/letsencrypt/archive/ドメイン/ 以下に4ファ...
-cert1.pem サーバ証明書(公開鍵)
-chain1.pem 中間証明書
-fullchain1.pem サーバ証明書と中間証明書が結合されたファ...
-privkey1.pem 秘密鍵
数字は更新するたびにインクリメントされるようです。~
シンボリックリンクが以下に作成されるので、WEBサーバへの設...
-/etc/letsencrypt/live/ドメイン/cert.pem
-/etc/letsencrypt/live/ドメイン/chain.pem
-/etc/letsencrypt/live/ドメイン/fullchain.pem
-/etc/letsencrypt/live/ドメイン/privkey.pem
Apache 2.4.8未満では公開鍵、中間証明書、秘密鍵を使用しま...
それ以上やNginxではサーバ証明書と中間証明書が結合されたフ...
**WEBサーバを停止せずに証明書を取得する [#t3f3a884]
Webrootプラグインを使用することでWEBサーバを停止すること...
WEBサーバで公開している絶対パスを指定します。
# ./certbot-auto certonly --webroot -w /home/example.com...
Alias設定をしている場合は以下になります。
# ./certbot-auto certonly --webroot -w /home/example.com...
複数のドメインで1つの証明書を取得する場合は以下になります。
# ./certbot-auto certonly --webroot -w /home/example.com...
Webrootプラグインを使用すると、/home/example.com/public_h...
**ワイルドカード証明書を取得する [#lcbbf641]
2018年3月頃にLet's Encryptがワイルドカードの証明書に対応...
メールアドレスとドメインを指定してコマンドを実行します。
# ./certbot-auto certonly \
--manual \
--preferred-challenges dns-01 \
--server https://acme-v02.api.letsencrypt.org/directory \
--agree-tos \
--manual-public-ip-logging-ok \
-m "user@example.com" \
-d "example.com" \
-d "*.example.com"
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator manual, Installer None
Obtaining a new certificate
Performing the following challenges:
dns-01 challenge for example.com
dns-01 challenge for example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - ...
Please deploy a DNS TXT record under the name
_acme-challenge.example.com with the following value:
*******************************************
Before continuing, verify the record is deployed.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - ...
Press Enter to Continue
指示された通りに _acme-challenge.example.com のtxtレコー...
反映されたかの確認は以下で行います。
$ dig @ns1.example.com _acme-challenge.example.com txt
反映確認後にEnter
Please deploy a DNS TXT record under the name
_acme-challenge.example.com with the following value:
*******************************************
Before continuing, verify the record is deployed.
(This must be set up in addition to the previous challen...
replace, or undo the previous challenge tasks yet. Note ...
asked to create multiple distinct TXT records with the s...
permitted by DNS standards.)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - ...
Press Enter to Continue
先程のものに追加でtxtレコードを追加し、反映確認後にEnter...
更新時も同様の手順を行います。~
初回取得時に設定しているtxtレコードは削除しても大丈夫です。
*Apacheの設定 [#a6784222]
ソースでインストールしている場合は --enable-ssl が有効に...
以下の行があるか確認します。
LoadModule ssl_module modules/mod_ssl.so
以下をApacheの設定ファイルに追加します。
Apache 2.4.8未満の場合
Listen 443
<VirtualHost *:443>
ServerName ドメイン:443
DocumentRoot "/home/ドメイン/public_html"
SSLEngine on
SSLHonorCipherOrder on
Header set Strict-Transport-Security "max-age=315360...
SSLProtocol -All +TLSv1 +TLSv1.1 +TLSv1.2
SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5
SSLCertificateFile /etc/letsencrypt/live/ドメイン/ce...
SSLCertificateKeyFile /etc/letsencrypt/live/ドメイン...
SSLCertificateChainFile /etc/letsencrypt/live/ドメイ...
<Directory "/home/ドメイン/public_html">
Options FollowSymLinks
AllowOverride ALL
Require all granted
</Directory>
ErrorLog "logs/ssl_error_log"
CustomLog "logs/ssl_access_log" combined
</VirtualHost>
Apache 2.4.8以降の場合
<VirtualHost *:443>
ServerName ドメイン:443
DocumentRoot "/home/ドメイン/public_html"
SSLEngine on
SSLHonorCipherOrder on
Header set Strict-Transport-Security "max-age=315360...
SSLProtocol -All +TLSv1 +TLSv1.1 +TLSv1.2
SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5
SSLCertificateFile /etc/letsencrypt/live/ドメイン/fu...
SSLCertificateKeyFile /etc/letsencrypt/live/ドメイン...
<Directory "/home/ドメイン/public_html">
Options FollowSymLinks
AllowOverride ALL
Require all granted
</Directory>
ErrorLog "logs/ssl_error_log"
CustomLog "logs/ssl_access_log" combined
</VirtualHost>
**httpへのアクセスをhttpsへ転送させる [#h2c276fa]
.htaccessを設置してhttpにアクセスがあった場合はhttpsへそ...
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R...
*自動更新の設定 [#peb4c288]
crontabに登録しておくことで自動更新が可能です。
通常はこんな感じ
0 9 * * * /pathto/certbot-auto renew --post-hook "/etc/r...
毎月1日午前9時に一括更新する場合
0 9 1 * * /etc/rc.d/init.d/httpd stop && /pathto/certbot...
毎月1日午前9時に特定のドメインを更新する場合
0 9 1 * * /etc/rc.d/init.d/httpd stop && /pathto/certbot...
ログは /var/log/letsencrypt/letsencrypt.log に出力されて...
*有効期限などの確認 [#af066d19]
# ./certbot-auto certificates
--------------------------------------------------------...
Found the following certs:
Certificate Name: example.com
Domains: example.com
Expiry Date: 2017-08-22 23:01:00+00:00 (VALID: 55 da...
Certificate Path: /etc/letsencrypt/live/example.com/...
Private Key Path: /etc/letsencrypt/live/example.com/...
--------------------------------------------------------...
*証明書の破棄 [#da7294f1]
以下のコマンドで削除するドメインを聞かれるので、番号を選...
# ./certbot-auto delete -d sub.example.com
Which certificate(s) would you like to delete?
*登録しているメールアドレスの確認 [#h5e7c302]
# cat /etc/letsencrypt/accounts/acme-v02.api.letsencrypt...
contactに指定されているものがそうです。
*pip UnicodeDecodeError [#e2090d89]
エラーが出て実行できないようになりました。
# ./certbot-auto
Creating virtual environment...
Installing Python packages...
Had a problem while installing Python packages.
pip prints the following errors:
=====================================================
DEPRECATION: Python 2.6 is no longer supported by the Py...
Traceback (most recent call last):
File "/opt/eff.org/certbot/venv/lib/python2.6/site-pac...
status = self.run(options, args)
File "/opt/eff.org/certbot/venv/lib/python2.6/site-pac...
with self._build_session(options) as session:
File "/opt/eff.org/certbot/venv/lib/python2.6/site-pac...
insecure_hosts=options.trusted_hosts,
File "/opt/eff.org/certbot/venv/lib/python2.6/site-pac...
self.headers["User-Agent"] = user_agent()
File "/opt/eff.org/certbot/venv/lib/python2.6/site-pac...
from pip._vendor import distro
File "/opt/eff.org/certbot/venv/lib/python2.6/site-pac...
_distro = LinuxDistribution()
File "/opt/eff.org/certbot/venv/lib/python2.6/site-pac...
if include_lsb else {}
File "/opt/eff.org/certbot/venv/lib/python2.6/site-pac...
stdout, stderr = stdout.decode('utf-8'), stderr.deco...
File "/opt/eff.org/certbot/venv/lib64/python2.6/encodi...
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xa5 ...
=====================================================
Certbot has problem setting up the virtual environment.
We were not be able to guess the right solution from you...
Consult https://certbot.eff.org/docs/install.html#proble...
You may also find some support resources at https://cert...
サーバをEUC-JPで設定していることが原因のようです。
# cat /etc/sysconfig/i18n
LANG="ja_JP.eucJP"
これで動きました。
# LANG=ja_JP.UTF-8 ./certbot-auto
*CentOS6.2でPython 3.5以上が必要と言われた [#u46e4ebb]
# ./certbot-auto renew
WARNING: couldn't find Python 3.5+ to check for updates.
Traceback (most recent call last):
File "<stdin>", line 16, in <module>
File "/usr/lib64/python3.4/distutils/version.py", line...
c = self._cmp(other)
File "/usr/lib64/python3.4/distutils/version.py", line...
if self.version != other.version:
AttributeError: 'StrictVersion' object has no attribute ...
# yum install -y https://centos6.iuscommunity.org/ius-re...
# yum install --enablerepo=ius python36 python36-libs py...
# ln -s /usr/bin/python3.6 /usr/bin/python3
# ln -s /usr/bin/pip3.6 /usr/bin/pip3
*couldn't get currently installed version [#y161bce1]
# ./certbot-auto renew
Upgrading certbot-auto 0.40.0 to 0.40.1...
Replacing certbot-auto...
Error: couldn't get currently installed version for /opt...
Traceback (most recent call last):
File "/opt/eff.org/certbot/venv/bin/letsencrypt", line...
from pkg_resources import load_entry_point
ModuleNotFoundError: No module named 'pkg_resources'
フォルダを削除してしまいます。
# rm -fr /opt/eff.org/certbot/
*CentOS5で導入する [#x92b8031]
CentOS5ではPythonのバージョンが古いため動作しません。~
互換クライアントがあるようなので、[[dehydrated:https://gi...
https://community.letsencrypt.org/t/list-of-client-implem...
**dehydratedの設置 [#mdbd26f3]
[[GitHub:https://github.com/lukas2511/dehydrated]]から de...
# mkdir /usr/local/etc/dehydrated
解凍したファイル類をアップします。
# cp /usr/local/etc/dehydrated/docs/examples/config /usr...
証明書を取得するドメインを指定します。~
複数の場合は半角スペースで区切ります。
# echo 'example.com' > /usr/local/etc/dehydrated/domains...
**Apacheの設定 [#t19741b6]
***Apacheをパッケージでインストールしている場合 [#dd8a2779]
# mkdir /var/www/dehydrated
# mkdir -p /var/www/html/.well-known/acme-challenge
# vi /etc/httpd/conf/httpd.conf
<IfModule alias_module>
Alias /.well-known/acme-challenge /var/www/dehydrated
</IfModule>
***Apacheをソースからインストールしている場合 [#wa6fc244]
# mkdir /usr/local/apache2/htdocs/dehydrated
# mkdir -p /usr/local/apache2/htdocs/.well-known/acme-ch...
# vi /usr/local/apache2/conf/httpd.conf
<IfModule alias_module>
Alias /.well-known/acme-challenge /usr/local/apache2...
</IfModule>
**アカウントを登録 [#i08a8024]
# /usr/local/etc/dehydrated/dehydrated --register --acce...
エラーが出た…
ERROR: Problem connecting to server (get for https://acm...
ルート証明書が古いことが原因らしいので、新しい証明書を取...
# wget https://curl.haxx.se/ca/cacert.pem
OpenSSL: error:1407742E:SSL routines:SSL23_GET_SERVER_HE...
SSL による接続が確立できません。
# wget --secure-protocol=SSLv2 https://curl.haxx.se/ca/c...
curl.haxx.se|151.101.90.49|:443 に接続しています... 接続...
SSL による接続が確立できません。
ダメだ…。~
手元のパソコンでダウンロードしてからサーバへアップ。屈辱的…
# cd /etc/pki/tls/certs
# mv ca-bundle.crt ca-bundle.crt.org
# mv cacert.pem ca-bundle.crt
# /usr/local/etc/dehydrated/dehydrated --register --acce...
エラーが出た…
ERROR: Problem connecting to server (get for https://acm...
opensslのバージョンが古いせいらしい。~
↑これは違うみたい
# yum update openssl openssl-devel
Loaded plugins: fastestmirror
Determining fastest mirrors
YumRepo Error: All mirror URLs are not using ftp, http[s...
Eg. Invalid release/
removing mirrorlist with no valid mirrors: /var/cache/yu...
Error: Cannot find a valid baseurl for repo: addons
# vi CentOS-Base.repo
各mirrorlist, baseurlをコメントにし、それぞれ追加
[base]
baseurl=http://vault.centos.org/5.5/os/$basearch/
[updates]
baseurl=http://vault.centos.org/5.5/updates/$basearch/
[addons]
baseurl=http://vault.centos.org/5.5/addons/$basearch/
[extras]
baseurl=http://vault.centos.org/5.5/extras/$basearch/
[centosplus]
baseurl=http://vault.centos.org/5.5/centosplus/$basearch/
[contrib]
baseurl=http://vault.centos.org/5.5/contrib/$basearch/
curlが古いみたい~
tarをダウンロード~
https://curl.haxx.se/download.html
# tar xvzf curl-7.58.0.tar.gz
# cd curl-7.58.0
# ./configure --enable-libcurl-option
# make install
改めてアカウントを登録
# /usr/local/etc/dehydrated/dehydrated --register --acce...
# INFO: Using main config file /usr/local/etc/dehydrated...
+ Generating account key...
+ Registering account key with ACME server...
+ Done!
これで /usr/local/etc/dehydrated/accounts 以下が生成され...
**証明書の発行 [#v15a4714]
# /usr/local/etc/dehydrated/dehydrated --config /usr/loc...
# INFO: Using main config file /usr/local/etc/dehydrated...
Processing example.com
+ Signing domains...
+ Generating private key...
+ Generating signing request...
+ Requesting authorization for example.com...
中略
+ Done!
sedのオプションエラーが出たけど /usr/local/etc/dehydrated...
**証明書をApacheに設定 [#cc93ac35]
上記の方法でApacheにSSLの設定をします。
SSLCertificateFile /usr/local/etc/dehydrated/certs/ex...
SSLCertificateKeyFile /usr/local/etc/dehydrated/certs...
SSLCertificateChainFile /usr/local/etc/dehydrated/cer...
**証明書の更新 [#b90e6dc6]
cronで取得時と同様にコマンド実行で可能なようです。
# /usr/local/etc/dehydrated/dehydrated --config /usr/loc...
**有効期限の確認 [#vdbf9fb2]
$ openssl s_client -connect example.com:443 < /dev/null ...
Not After : May 11 08:35:01 2018 GMT
終了行:
[[Linuxめも]]
#contents
GoogleがやたらとSSL対応を勧めてくるんですよ。~
やっぱり今後はSSL対応が必須になる時代が来そうです。
でもSSLって高いイメージがあるし、証明書の更新も面倒。~
今の時代無料でできねーかなと調べてみたらなんかできそうな...
[[Let's Encrypt:https://letsencrypt.jp/]] で無料でSSLが導...
証明書の発行・インストール・更新のプロセスを自動化できる...
制限があります。~
https://letsencrypt.org/docs/rate-limits/
制限についての説明はこちらが詳しいです。~
ありがとうございます。~
http://qiita.com/sawanoboly/items/8e3c57aa2e30fc58c4e3
参考
-https://def-4.com/lets-encrypt-multi-domains/
-https://def-4.com/letsencrypt-tls-sni-01-challenge-error/
-https://blog.apar.jp/linux/3619/
-http://qiita.com/tkykmw/items/9b6ba55bb2a6a5d90963
*certbotのインストールと自動更新設定 [#o133672c]
# yum install certbot
# yum install python2-certbot-apache
# certbot --apache -d example.com
# service httpd graceful
更新対象が無い場合はスキップされるので毎日実行しても大丈...
結果はメールで確認できるようにします。~
hookが必要かどうかは確認中。
# root
#5 9 * * * /usr/bin/certbot renew --post-hook "systemctl...
5 9 * * * /usr/bin/certbot renew 2>&1 | mail -s "Let's E...
※以下は古い内容です。
*クライアントソフトCertbotのインストール [#w457122c]
# wget https://dl.eff.org/certbot-auto
# chmod 700 certbot-auto
ヘルプは以下で確認できます。
# ./certbot-auto --help
以下を実行すると、自動的にyumが実行され、必要なパッケージ...
# ./certbot-auto
CentOS6.2ではyumにて python-pip-1.3.1-4.el6.noarch がダウ...
epelリポジトリを入れるとハマるみたいです。~
設定を書き換えます。
# vi /etc/yum.repos.d/epel.repo
#baseurl=http://download.fedoraproject.org/pub/epel/6/$b...
mirrorlist=https://mirrors.fedoraproject.org/metalink?re...
↓
baseurl=http://download.fedoraproject.org/pub/epel/6/$ba...
#mirrorlist=https://mirrors.fedoraproject.org/metalink?r...
CentOS5.5など古いOSは以下を参考にさせてもらえば利用が可能...
https://clouds.tokyo/blog/linux_lets_cent5/
*証明書の取得 [#ede60d3a]
同一サーバで別ドメインの証明書を取得する場合は、443ポート...
そのため開始前にWEBサーバを止めておきます。~
また、メールアドレスの入力と同意の設問はスキップされます。
# ./certbot-auto certonly
How would you like to authenticate with the ACME CA?
--------------------------------------------------------...
1: Place files in webroot directory (webroot)
2: Spin up a temporary webserver (standalone)
--------------------------------------------------------...
Select the appropriate number [1-2] then [enter] (press ...
2を入力~
※certbot-autoのバージョンが上がって順番が入れ替わっている...
Enter email address (used for urgent renewal and securit...
メールアドレスを入力
--------------------------------------------------------...
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.1.1-August-1-...
in order to register with the ACME server at
https://acme-v01.api.letsencrypt.org/directory
--------------------------------------------------------...
(A)gree/(C)ancel:
Aを入力
Please enter in your domain name(s) (comma and/or space ...
証明書を導入したいドメインをカンマもしくはスペース区切り...
成功すれば /etc/letsencrypt/archive/ドメイン/ 以下に4ファ...
-cert1.pem サーバ証明書(公開鍵)
-chain1.pem 中間証明書
-fullchain1.pem サーバ証明書と中間証明書が結合されたファ...
-privkey1.pem 秘密鍵
数字は更新するたびにインクリメントされるようです。~
シンボリックリンクが以下に作成されるので、WEBサーバへの設...
-/etc/letsencrypt/live/ドメイン/cert.pem
-/etc/letsencrypt/live/ドメイン/chain.pem
-/etc/letsencrypt/live/ドメイン/fullchain.pem
-/etc/letsencrypt/live/ドメイン/privkey.pem
Apache 2.4.8未満では公開鍵、中間証明書、秘密鍵を使用しま...
それ以上やNginxではサーバ証明書と中間証明書が結合されたフ...
**WEBサーバを停止せずに証明書を取得する [#t3f3a884]
Webrootプラグインを使用することでWEBサーバを停止すること...
WEBサーバで公開している絶対パスを指定します。
# ./certbot-auto certonly --webroot -w /home/example.com...
Alias設定をしている場合は以下になります。
# ./certbot-auto certonly --webroot -w /home/example.com...
複数のドメインで1つの証明書を取得する場合は以下になります。
# ./certbot-auto certonly --webroot -w /home/example.com...
Webrootプラグインを使用すると、/home/example.com/public_h...
**ワイルドカード証明書を取得する [#lcbbf641]
2018年3月頃にLet's Encryptがワイルドカードの証明書に対応...
メールアドレスとドメインを指定してコマンドを実行します。
# ./certbot-auto certonly \
--manual \
--preferred-challenges dns-01 \
--server https://acme-v02.api.letsencrypt.org/directory \
--agree-tos \
--manual-public-ip-logging-ok \
-m "user@example.com" \
-d "example.com" \
-d "*.example.com"
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator manual, Installer None
Obtaining a new certificate
Performing the following challenges:
dns-01 challenge for example.com
dns-01 challenge for example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - ...
Please deploy a DNS TXT record under the name
_acme-challenge.example.com with the following value:
*******************************************
Before continuing, verify the record is deployed.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - ...
Press Enter to Continue
指示された通りに _acme-challenge.example.com のtxtレコー...
反映されたかの確認は以下で行います。
$ dig @ns1.example.com _acme-challenge.example.com txt
反映確認後にEnter
Please deploy a DNS TXT record under the name
_acme-challenge.example.com with the following value:
*******************************************
Before continuing, verify the record is deployed.
(This must be set up in addition to the previous challen...
replace, or undo the previous challenge tasks yet. Note ...
asked to create multiple distinct TXT records with the s...
permitted by DNS standards.)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - ...
Press Enter to Continue
先程のものに追加でtxtレコードを追加し、反映確認後にEnter...
更新時も同様の手順を行います。~
初回取得時に設定しているtxtレコードは削除しても大丈夫です。
*Apacheの設定 [#a6784222]
ソースでインストールしている場合は --enable-ssl が有効に...
以下の行があるか確認します。
LoadModule ssl_module modules/mod_ssl.so
以下をApacheの設定ファイルに追加します。
Apache 2.4.8未満の場合
Listen 443
<VirtualHost *:443>
ServerName ドメイン:443
DocumentRoot "/home/ドメイン/public_html"
SSLEngine on
SSLHonorCipherOrder on
Header set Strict-Transport-Security "max-age=315360...
SSLProtocol -All +TLSv1 +TLSv1.1 +TLSv1.2
SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5
SSLCertificateFile /etc/letsencrypt/live/ドメイン/ce...
SSLCertificateKeyFile /etc/letsencrypt/live/ドメイン...
SSLCertificateChainFile /etc/letsencrypt/live/ドメイ...
<Directory "/home/ドメイン/public_html">
Options FollowSymLinks
AllowOverride ALL
Require all granted
</Directory>
ErrorLog "logs/ssl_error_log"
CustomLog "logs/ssl_access_log" combined
</VirtualHost>
Apache 2.4.8以降の場合
<VirtualHost *:443>
ServerName ドメイン:443
DocumentRoot "/home/ドメイン/public_html"
SSLEngine on
SSLHonorCipherOrder on
Header set Strict-Transport-Security "max-age=315360...
SSLProtocol -All +TLSv1 +TLSv1.1 +TLSv1.2
SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5
SSLCertificateFile /etc/letsencrypt/live/ドメイン/fu...
SSLCertificateKeyFile /etc/letsencrypt/live/ドメイン...
<Directory "/home/ドメイン/public_html">
Options FollowSymLinks
AllowOverride ALL
Require all granted
</Directory>
ErrorLog "logs/ssl_error_log"
CustomLog "logs/ssl_access_log" combined
</VirtualHost>
**httpへのアクセスをhttpsへ転送させる [#h2c276fa]
.htaccessを設置してhttpにアクセスがあった場合はhttpsへそ...
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R...
*自動更新の設定 [#peb4c288]
crontabに登録しておくことで自動更新が可能です。
通常はこんな感じ
0 9 * * * /pathto/certbot-auto renew --post-hook "/etc/r...
毎月1日午前9時に一括更新する場合
0 9 1 * * /etc/rc.d/init.d/httpd stop && /pathto/certbot...
毎月1日午前9時に特定のドメインを更新する場合
0 9 1 * * /etc/rc.d/init.d/httpd stop && /pathto/certbot...
ログは /var/log/letsencrypt/letsencrypt.log に出力されて...
*有効期限などの確認 [#af066d19]
# ./certbot-auto certificates
--------------------------------------------------------...
Found the following certs:
Certificate Name: example.com
Domains: example.com
Expiry Date: 2017-08-22 23:01:00+00:00 (VALID: 55 da...
Certificate Path: /etc/letsencrypt/live/example.com/...
Private Key Path: /etc/letsencrypt/live/example.com/...
--------------------------------------------------------...
*証明書の破棄 [#da7294f1]
以下のコマンドで削除するドメインを聞かれるので、番号を選...
# ./certbot-auto delete -d sub.example.com
Which certificate(s) would you like to delete?
*登録しているメールアドレスの確認 [#h5e7c302]
# cat /etc/letsencrypt/accounts/acme-v02.api.letsencrypt...
contactに指定されているものがそうです。
*pip UnicodeDecodeError [#e2090d89]
エラーが出て実行できないようになりました。
# ./certbot-auto
Creating virtual environment...
Installing Python packages...
Had a problem while installing Python packages.
pip prints the following errors:
=====================================================
DEPRECATION: Python 2.6 is no longer supported by the Py...
Traceback (most recent call last):
File "/opt/eff.org/certbot/venv/lib/python2.6/site-pac...
status = self.run(options, args)
File "/opt/eff.org/certbot/venv/lib/python2.6/site-pac...
with self._build_session(options) as session:
File "/opt/eff.org/certbot/venv/lib/python2.6/site-pac...
insecure_hosts=options.trusted_hosts,
File "/opt/eff.org/certbot/venv/lib/python2.6/site-pac...
self.headers["User-Agent"] = user_agent()
File "/opt/eff.org/certbot/venv/lib/python2.6/site-pac...
from pip._vendor import distro
File "/opt/eff.org/certbot/venv/lib/python2.6/site-pac...
_distro = LinuxDistribution()
File "/opt/eff.org/certbot/venv/lib/python2.6/site-pac...
if include_lsb else {}
File "/opt/eff.org/certbot/venv/lib/python2.6/site-pac...
stdout, stderr = stdout.decode('utf-8'), stderr.deco...
File "/opt/eff.org/certbot/venv/lib64/python2.6/encodi...
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xa5 ...
=====================================================
Certbot has problem setting up the virtual environment.
We were not be able to guess the right solution from you...
Consult https://certbot.eff.org/docs/install.html#proble...
You may also find some support resources at https://cert...
サーバをEUC-JPで設定していることが原因のようです。
# cat /etc/sysconfig/i18n
LANG="ja_JP.eucJP"
これで動きました。
# LANG=ja_JP.UTF-8 ./certbot-auto
*CentOS6.2でPython 3.5以上が必要と言われた [#u46e4ebb]
# ./certbot-auto renew
WARNING: couldn't find Python 3.5+ to check for updates.
Traceback (most recent call last):
File "<stdin>", line 16, in <module>
File "/usr/lib64/python3.4/distutils/version.py", line...
c = self._cmp(other)
File "/usr/lib64/python3.4/distutils/version.py", line...
if self.version != other.version:
AttributeError: 'StrictVersion' object has no attribute ...
# yum install -y https://centos6.iuscommunity.org/ius-re...
# yum install --enablerepo=ius python36 python36-libs py...
# ln -s /usr/bin/python3.6 /usr/bin/python3
# ln -s /usr/bin/pip3.6 /usr/bin/pip3
*couldn't get currently installed version [#y161bce1]
# ./certbot-auto renew
Upgrading certbot-auto 0.40.0 to 0.40.1...
Replacing certbot-auto...
Error: couldn't get currently installed version for /opt...
Traceback (most recent call last):
File "/opt/eff.org/certbot/venv/bin/letsencrypt", line...
from pkg_resources import load_entry_point
ModuleNotFoundError: No module named 'pkg_resources'
フォルダを削除してしまいます。
# rm -fr /opt/eff.org/certbot/
*CentOS5で導入する [#x92b8031]
CentOS5ではPythonのバージョンが古いため動作しません。~
互換クライアントがあるようなので、[[dehydrated:https://gi...
https://community.letsencrypt.org/t/list-of-client-implem...
**dehydratedの設置 [#mdbd26f3]
[[GitHub:https://github.com/lukas2511/dehydrated]]から de...
# mkdir /usr/local/etc/dehydrated
解凍したファイル類をアップします。
# cp /usr/local/etc/dehydrated/docs/examples/config /usr...
証明書を取得するドメインを指定します。~
複数の場合は半角スペースで区切ります。
# echo 'example.com' > /usr/local/etc/dehydrated/domains...
**Apacheの設定 [#t19741b6]
***Apacheをパッケージでインストールしている場合 [#dd8a2779]
# mkdir /var/www/dehydrated
# mkdir -p /var/www/html/.well-known/acme-challenge
# vi /etc/httpd/conf/httpd.conf
<IfModule alias_module>
Alias /.well-known/acme-challenge /var/www/dehydrated
</IfModule>
***Apacheをソースからインストールしている場合 [#wa6fc244]
# mkdir /usr/local/apache2/htdocs/dehydrated
# mkdir -p /usr/local/apache2/htdocs/.well-known/acme-ch...
# vi /usr/local/apache2/conf/httpd.conf
<IfModule alias_module>
Alias /.well-known/acme-challenge /usr/local/apache2...
</IfModule>
**アカウントを登録 [#i08a8024]
# /usr/local/etc/dehydrated/dehydrated --register --acce...
エラーが出た…
ERROR: Problem connecting to server (get for https://acm...
ルート証明書が古いことが原因らしいので、新しい証明書を取...
# wget https://curl.haxx.se/ca/cacert.pem
OpenSSL: error:1407742E:SSL routines:SSL23_GET_SERVER_HE...
SSL による接続が確立できません。
# wget --secure-protocol=SSLv2 https://curl.haxx.se/ca/c...
curl.haxx.se|151.101.90.49|:443 に接続しています... 接続...
SSL による接続が確立できません。
ダメだ…。~
手元のパソコンでダウンロードしてからサーバへアップ。屈辱的…
# cd /etc/pki/tls/certs
# mv ca-bundle.crt ca-bundle.crt.org
# mv cacert.pem ca-bundle.crt
# /usr/local/etc/dehydrated/dehydrated --register --acce...
エラーが出た…
ERROR: Problem connecting to server (get for https://acm...
opensslのバージョンが古いせいらしい。~
↑これは違うみたい
# yum update openssl openssl-devel
Loaded plugins: fastestmirror
Determining fastest mirrors
YumRepo Error: All mirror URLs are not using ftp, http[s...
Eg. Invalid release/
removing mirrorlist with no valid mirrors: /var/cache/yu...
Error: Cannot find a valid baseurl for repo: addons
# vi CentOS-Base.repo
各mirrorlist, baseurlをコメントにし、それぞれ追加
[base]
baseurl=http://vault.centos.org/5.5/os/$basearch/
[updates]
baseurl=http://vault.centos.org/5.5/updates/$basearch/
[addons]
baseurl=http://vault.centos.org/5.5/addons/$basearch/
[extras]
baseurl=http://vault.centos.org/5.5/extras/$basearch/
[centosplus]
baseurl=http://vault.centos.org/5.5/centosplus/$basearch/
[contrib]
baseurl=http://vault.centos.org/5.5/contrib/$basearch/
curlが古いみたい~
tarをダウンロード~
https://curl.haxx.se/download.html
# tar xvzf curl-7.58.0.tar.gz
# cd curl-7.58.0
# ./configure --enable-libcurl-option
# make install
改めてアカウントを登録
# /usr/local/etc/dehydrated/dehydrated --register --acce...
# INFO: Using main config file /usr/local/etc/dehydrated...
+ Generating account key...
+ Registering account key with ACME server...
+ Done!
これで /usr/local/etc/dehydrated/accounts 以下が生成され...
**証明書の発行 [#v15a4714]
# /usr/local/etc/dehydrated/dehydrated --config /usr/loc...
# INFO: Using main config file /usr/local/etc/dehydrated...
Processing example.com
+ Signing domains...
+ Generating private key...
+ Generating signing request...
+ Requesting authorization for example.com...
中略
+ Done!
sedのオプションエラーが出たけど /usr/local/etc/dehydrated...
**証明書をApacheに設定 [#cc93ac35]
上記の方法でApacheにSSLの設定をします。
SSLCertificateFile /usr/local/etc/dehydrated/certs/ex...
SSLCertificateKeyFile /usr/local/etc/dehydrated/certs...
SSLCertificateChainFile /usr/local/etc/dehydrated/cer...
**証明書の更新 [#b90e6dc6]
cronで取得時と同様にコマンド実行で可能なようです。
# /usr/local/etc/dehydrated/dehydrated --config /usr/loc...
**有効期限の確認 [#vdbf9fb2]
$ openssl s_client -connect example.com:443 < /dev/null ...
Not After : May 11 08:35:01 2018 GMT
ページ名: