無料ssl Let's Encrypt を設定してみる

centos7 Let's Encrypt の使い方

[code lang=text] [asteltk2-234-26965 ] $ git --version git version 1.8.3.1 [asteltk2-234-26965 ] $ mkdir letsencrypt [asteltk2-234-26965 ] $ cd letsencrypt [asteltk2-234-26965 ] $ git clone https://github.com/certbot/certbot Cloning into 'certbot'... remote: Counting objects: 35434, done. remote: Total 35434 (delta 0), reused 0 (delta 0), pack-reused 35433 Receiving objects: 100% (35434/35434), 9.39 MiB | 1.39 MiB/s, done. Resolving deltas: 100% (25180/25180), done. [asteltk2-234-26965 ] $ [asteltk2-234-26965 ] $ [asteltk2-234-26965 ] $ [asteltk2-234-26965 ] $ cd certbot/ [asteltk2-234-26965 ] $ ./certbot-auto --help Usage: certbot-auto [OPTIONS] A self-updating wrapper script for the Certbot ACME client. When run, updates to both this script and certbot will be downloaded and installed. After ensuring you have the latest versions installed, certbot will be invoked with all arguments you have provided.

Help for certbot itself cannot be provided until it is installed.

--debug attempt experimental installation -h, --help print this help -n, --non-interactive, --noninteractive run without asking for user input --no-self-upgrade do not download updates --os-packages-only install OS dependencies and exit -v, --verbose provide more output

All arguments are accepted and forwarded to the Certbot client when run. [asteltk2-234-26965 ] $
[asteltk2-234-26965 ] $ [asteltk2-234-26965 ] $ sudo ./certbot-auto --help Usage: certbot-auto [OPTIONS] A self-updating wrapper script for the Certbot ACME client. When run, updates to both this script and certbot will be downloaded and installed. After ensuring you have the latest versions installed, certbot will be invoked with all arguments you have provided.

Help for certbot itself cannot be provided until it is installed.

--debug attempt experimental installation -h, --help print this help -n, --non-interactive, --noninteractive run without asking for user input --no-self-upgrade do not download updates --os-packages-only install OS dependencies and exit -v, --verbose provide more output

All arguments are accepted and forwarded to the Certbot client when run. [asteltk2-234-26965 ] $ [asteltk2-234-26965 ] $ [asteltk2-234-26965 ] $ pwd
/home/astel/letsencrypt/certbot [asteltk2-234-26965 ] $ ls CHANGES.rst MANIFEST.in certbot-apache docs letsencrypt-auto-source pep8.travis.sh tools CONTRIBUTING.md README.rst certbot-auto examples letsencrypt-nginx readthedocs.org.requirements.txt tox.cover.sh Dockerfile Vagrantfile certbot-compatibility-test letsencrypt letshelp-certbot setup.cfg tox.ini Dockerfile-dev acme certbot-nginx letsencrypt-apache letshelp-letsencrypt setup.py LICENSE.txt certbot docker-compose.yml letsencrypt-auto linter_plugin.py tests [asteltk2-234-26965 ] $
[asteltk2-234-26965 ] $ [asteltk2-234-26965 ] $ pwd /home/astel/letsencrypt/certbot [asteltk2-234-26965 ] $ ./certbot-auto certonly -a standalone -d astail.net Bootstrapping dependencies for RedHat-based OSes... yum は /usr/bin/yum です 読み込んだプラグイン:fastestmirror, langpacks, priorities base | 3.6 kB 00:00:00
epel/x86_64/metalink | 5.1 kB 00:00:00
epel | 4.3 kB 00:00:00
extras | 3.4 kB 00:00:00
mysql-connectors-community | 2.5 kB 00:00:00
mysql-tools-community | 2.5 kB 00:00:00
mysql57-community | 2.5 kB 00:00:00
nginx | 2.9 kB 00:00:00
remi-safe | 2.9 kB 00:00:00
rpmforge | 1.9 kB 00:00:00
treasuredata | 2.9 kB 00:00:00
updates | 3.4 kB 00:00:00
zabbix | 951 B 00:00:00
zabbix-non-supported | 951 B 00:00:00
(1/5): extras/7/x86_64/primary_db | 117 kB 00:00:00
(2/5): epel/x86_64/updateinfo | 552 kB 00:00:00
(3/5): remi-safe/primary_db | 391 kB 00:00:00
(4/5): epel/x86_64/primary_db | 4.1 MB 00:00:01
(5/5): updates/7/x86_64/primary_db | 4.8 MB 00:00:01
Loading mirror speeds from cached hostfile * base: ftp.tsukuba.wide.ad.jp * epel: ftp.kddilabs.jp * extras: ftp.tsukuba.wide.ad.jp * remi-safe: mirrors.thzhost.com * rpmforge: ftp.kddilabs.jp * updates: ftp.tsukuba.wide.ad.jp パッケージ gcc-4.8.5-4.el7.x86_64 はインストール済みか最新バージョンです パッケージ augeas-libs-1.4.0-2.el7.x86_64 はインストール済みか最新バージョンです パッケージ redhat-rpm-config-9.1.0-68.el7.centos.noarch はインストール済みか最新バージョンです パッケージ ca-certificates-2015.2.6-70.1.el7_2.noarch はインストール済みか最新バージョンです パッケージ python-2.7.5-34.el7.x86_64 はインストール済みか最新バージョンです 依存性の解決をしています --> トランザクションの確認を実行しています。 ---> パッケージ dialog.x86_64 0:1.2-4.20130523.el7 を インストール ---> パッケージ libffi-devel.x86_64 0:3.0.13-16.el7 を インストール ---> パッケージ mod_ssl.x86_64 1:2.4.6-40.el7.centos.1 を インストール --> 依存性の処理をしています: httpd = 2.4.6-40.el7.centos.1 のパッケージ: 1:mod_ssl-2.4.6-40.el7.centos.1.x86_64 ---> パッケージ openssl.x86_64 1:1.0.1e-51.el7_2.4 を 更新 ---> パッケージ openssl.x86_64 1:1.0.1e-51.el7_2.5 を アップデート --> 依存性の処理をしています: openssl-libs(x86-64) = 1:1.0.1e-51.el7_2.5 のパッケージ: 1:openssl-1.0.1e-51.el7_2.5.x86_64 ---> パッケージ openssl-devel.x86_64 1:1.0.1e-51.el7_2.4 を 更新 ---> パッケージ openssl-devel.x86_64 1:1.0.1e-51.el7_2.5 を アップデート ---> パッケージ python-devel.x86_64 0:2.7.5-34.el7 を インストール ---> パッケージ python-pip.noarch 0:7.1.0-1.el7 を インストール --> 依存性の処理をしています: python-setuptools のパッケージ: python-pip-7.1.0-1.el7.noarch ---> パッケージ python-tools.x86_64 0:2.7.5-34.el7 を インストール --> 依存性の処理をしています: tkinter = 2.7.5-34.el7 のパッケージ: python-tools-2.7.5-34.el7.x86_64 ---> パッケージ python-virtualenv.noarch 0:1.10.1-2.el7 を インストール --> トランザクションの確認を実行しています。 ---> パッケージ httpd.x86_64 0:2.4.6-40.el7.centos を 更新 ---> パッケージ httpd.x86_64 0:2.4.6-40.el7.centos.1 を アップデート --> 依存性の処理をしています: httpd-tools = 2.4.6-40.el7.centos.1 のパッケージ: httpd-2.4.6-40.el7.centos.1.x86_64 ---> パッケージ openssl-libs.x86_64 1:1.0.1e-51.el7_2.4 を 更新 ---> パッケージ openssl-libs.x86_64 1:1.0.1e-51.el7_2.5 を アップデート ---> パッケージ python-setuptools.noarch 0:0.9.8-4.el7 を インストール --> 依存性の処理をしています: python-backports-ssl_match_hostname のパッケージ: python-setuptools-0.9.8-4.el7.noarch ---> パッケージ tkinter.x86_64 0:2.7.5-34.el7 を インストール --> 依存性の処理をしています: libtk8.5.so()(64bit) のパッケージ: tkinter-2.7.5-34.el7.x86_64 --> 依存性の処理をしています: libtcl8.5.so()(64bit) のパッケージ: tkinter-2.7.5-34.el7.x86_64 --> 依存性の処理をしています: libTix.so()(64bit) のパッケージ: tkinter-2.7.5-34.el7.x86_64 --> トランザクションの確認を実行しています。 ---> パッケージ httpd-tools.x86_64 0:2.4.6-40.el7.centos を 更新 ---> パッケージ httpd-tools.x86_64 0:2.4.6-40.el7.centos.1 を アップデート ---> パッケージ python-backports-ssl_match_hostname.noarch 0:3.4.0.2-4.el7 を インストール --> 依存性の処理をしています: python-backports のパッケージ: python-backports-ssl_match_hostname-3.4.0.2-4.el7.noarch ---> パッケージ tcl.x86_64 1:8.5.13-8.el7 を インストール ---> パッケージ tix.x86_64 1:8.4.3-12.el7 を インストール ---> パッケージ tk.x86_64 1:8.5.13-6.el7 を インストール --> 依存性の処理をしています: libXft.so.2()(64bit) のパッケージ: 1:tk-8.5.13-6.el7.x86_64 --> トランザクションの確認を実行しています。 ---> パッケージ libXft.x86_64 0:2.3.2-2.el7 を インストール ---> パッケージ python-backports.x86_64 0:1.0-8.el7 を インストール --> 依存性解決を終了しました。

依存性を解決しました


Package アーキテクチャー バージョン リポジトリー 容量

インストール中: dialog x86_64 1.2-4.20130523.el7 base 208 k libffi-devel x86_64 3.0.13-16.el7 base 23 k mod_ssl x86_64 1:2.4.6-40.el7.centos.1 updates 103 k python-devel x86_64 2.7.5-34.el7 base 391 k python-pip noarch 7.1.0-1.el7 epel 1.5 M python-tools x86_64 2.7.5-34.el7 base 850 k python-virtualenv noarch 1.10.1-2.el7 base 1.2 M 更新します: openssl x86_64 1:1.0.1e-51.el7_2.5 updates 712 k openssl-devel x86_64 1:1.0.1e-51.el7_2.5 updates 1.2 M 依存性関連でのインストールをします: libXft x86_64 2.3.2-2.el7 base 58 k python-backports x86_64 1.0-8.el7 base 5.8 k python-backports-ssl_match_hostname noarch 3.4.0.2-4.el7 base 12 k python-setuptools noarch 0.9.8-4.el7 base 396 k tcl x86_64 1:8.5.13-8.el7 base 1.9 M tix x86_64 1:8.4.3-12.el7 base 254 k tk x86_64 1:8.5.13-6.el7 base 1.4 M tkinter x86_64 2.7.5-34.el7 base 319 k 依存性関連での更新をします: httpd x86_64 2.4.6-40.el7.centos.1 updates 2.7 M httpd-tools x86_64 2.4.6-40.el7.centos.1 updates 82 k openssl-libs x86_64 1:1.0.1e-51.el7_2.5 updates 952 k

トランザクションの要約

インストール 7 パッケージ (+8 個の依存関係のパッケージ) 更新 2 パッケージ (+3 個の依存関係のパッケージ)

総ダウンロード容量: 14 M Is this ok [y/d/N]: y Downloading packages: Delta RPMs disabled because /usr/bin/applydeltarpm not installed. (1/20): libffi-devel-3.0.13-16.el7.x86_64.rpm | 23 kB 00:00:00
(2/20): libXft-2.3.2-2.el7.x86_64.rpm | 58 kB 00:00:00
(3/20): httpd-tools-2.4.6-40.el7.centos.1.x86_64.rpm | 82 kB 00:00:00
(4/20): dialog-1.2-4.20130523.el7.x86_64.rpm | 208 kB 00:00:00
(5/20): mod_ssl-2.4.6-40.el7.centos.1.x86_64.rpm | 103 kB 00:00:00
(6/20): openssl-1.0.1e-51.el7_2.5.x86_64.rpm | 712 kB 00:00:00
(7/20): openssl-devel-1.0.1e-51.el7_2.5.x86_64.rpm | 1.2 MB 00:00:00
(8/20): python-backports-ssl_match_hostname-3.4.0.2-4.el7.noarch.rpm | 12 kB 00:00:00
(9/20): python-backports-1.0-8.el7.x86_64.rpm | 5.8 kB 00:00:00
(10/20): python-devel-2.7.5-34.el7.x86_64.rpm | 391 kB 00:00:00
(11/20): python-setuptools-0.9.8-4.el7.noarch.rpm | 396 kB 00:00:00
(12/20): python-pip-7.1.0-1.el7.noarch.rpm | 1.5 MB 00:00:00
(13/20): openssl-libs-1.0.1e-51.el7_2.5.x86_64.rpm | 952 kB 00:00:00
(14/20): python-virtualenv-1.10.1-2.el7.noarch.rpm | 1.2 MB 00:00:00
(15/20): python-tools-2.7.5-34.el7.x86_64.rpm | 850 kB 00:00:00
(16/20): httpd-2.4.6-40.el7.centos.1.x86_64.rpm | 2.7 MB 00:00:01
(17/20): tkinter-2.7.5-34.el7.x86_64.rpm | 319 kB 00:00:00
(18/20): tix-8.4.3-12.el7.x86_64.rpm | 254 kB 00:00:00
(19/20): tcl-8.5.13-8.el7.x86_64.rpm | 1.9 MB 00:00:00

(20/20): tk-8.5.13-6.el7.x86_64.rpm | 1.4 MB 00:00:00

合計 7.5 MB/s | 14 MB 00:00:01
Running transaction check Running transaction test Transaction test succeeded Running transaction 更新します : 1:openssl-libs-1.0.1e-51.el7_2.5.x86_64 1/25 インストール中 : 1:tcl-8.5.13-8.el7.x86_64 2/25 更新します : httpd-tools-2.4.6-40.el7.centos.1.x86_64 3/25 更新します : httpd-2.4.6-40.el7.centos.1.x86_64 4/25 更新します : 1:openssl-1.0.1e-51.el7_2.5.x86_64 5/25 インストール中 : libXft-2.3.2-2.el7.x86_64 6/25 インストール中 : 1:tk-8.5.13-6.el7.x86_64 7/25 インストール中 : 1:tix-8.4.3-12.el7.x86_64 8/25 インストール中 : tkinter-2.7.5-34.el7.x86_64 9/25 インストール中 : python-backports-1.0-8.el7.x86_64 10/25 インストール中 : python-backports-ssl_match_hostname-3.4.0.2-4.el7.noarch 11/25 インストール中 : python-setuptools-0.9.8-4.el7.noarch 12/25 インストール中 : python-devel-2.7.5-34.el7.x86_64 13/25 インストール中 : python-virtualenv-1.10.1-2.el7.noarch 14/25 インストール中 : python-pip-7.1.0-1.el7.noarch 15/25 インストール中 : python-tools-2.7.5-34.el7.x86_64 16/25 インストール中 : 1:mod_ssl-2.4.6-40.el7.centos.1.x86_64 17/25 更新します : 1:openssl-devel-1.0.1e-51.el7_2.5.x86_64 18/25 インストール中 : libffi-devel-3.0.13-16.el7.x86_64 19/25 インストール中 : dialog-1.2-4.20130523.el7.x86_64 20/25 整理中 : 1:openssl-devel-1.0.1e-51.el7_2.4.x86_64 21/25 整理中 : httpd-2.4.6-40.el7.centos.x86_64 22/25 整理中 : httpd-tools-2.4.6-40.el7.centos.x86_64 23/25 整理中 : 1:openssl-1.0.1e-51.el7_2.4.x86_64 24/25 整理中 : 1:openssl-libs-1.0.1e-51.el7_2.4.x86_64 25/25 検証中 : 1:tcl-8.5.13-8.el7.x86_64 1/25 検証中 : python-backports-ssl_match_hostname-3.4.0.2-4.el7.noarch 2/25 検証中 : python-virtualenv-1.10.1-2.el7.noarch 3/25 検証中 : httpd-2.4.6-40.el7.centos.1.x86_64 4/25 検証中 : httpd-tools-2.4.6-40.el7.centos.1.x86_64 5/25 検証中 : 1:openssl-libs-1.0.1e-51.el7_2.5.x86_64 6/25 検証中 : 1:tix-8.4.3-12.el7.x86_64 7/25 検証中 : dialog-1.2-4.20130523.el7.x86_64 8/25 検証中 : tkinter-2.7.5-34.el7.x86_64 9/25 検証中 : python-setuptools-0.9.8-4.el7.noarch 10/25 検証中 : 1:tk-8.5.13-6.el7.x86_64 11/25 検証中 : libffi-devel-3.0.13-16.el7.x86_64 12/25 検証中 : python-devel-2.7.5-34.el7.x86_64 13/25 検証中 : 1:mod_ssl-2.4.6-40.el7.centos.1.x86_64 14/25 検証中 : 1:openssl-1.0.1e-51.el7_2.5.x86_64 15/25 検証中 : python-backports-1.0-8.el7.x86_64 16/25 検証中 : python-pip-7.1.0-1.el7.noarch 17/25 検証中 : libXft-2.3.2-2.el7.x86_64 18/25 検証中 : 1:openssl-devel-1.0.1e-51.el7_2.5.x86_64 19/25 検証中 : python-tools-2.7.5-34.el7.x86_64 20/25 検証中 : 1:openssl-1.0.1e-51.el7_2.4.x86_64 21/25 検証中 : httpd-tools-2.4.6-40.el7.centos.x86_64 22/25 検証中 : 1:openssl-devel-1.0.1e-51.el7_2.4.x86_64 23/25 検証中 : 1:openssl-libs-1.0.1e-51.el7_2.4.x86_64 24/25 検証中 : httpd-2.4.6-40.el7.centos.x86_64 25/25

インストール: dialog.x86_64 0:1.2-4.20130523.el7 libffi-devel.x86_64 0:3.0.13-16.el7 mod_ssl.x86_64 1:2.4.6-40.el7.centos.1 python-devel.x86_64 0:2.7.5-34.el7
python-pip.noarch 0:7.1.0-1.el7 python-tools.x86_64 0:2.7.5-34.el7 python-virtualenv.noarch 0:1.10.1-2.el7

依存性関連をインストールしました: libXft.x86_64 0:2.3.2-2.el7 python-backports.x86_64 0:1.0-8.el7 python-backports-ssl_match_hostname.noarch 0:3.4.0.2-4.el7 python-setuptools.noarch 0:0.9.8-4.el7 tcl.x86_64 1:8.5.13-8.el7 tix.x86_64 1:8.4.3-12.el7 tk.x86_64 1:8.5.13-6.el7 tkinter.x86_64 0:2.7.5-34.el7

更新: openssl.x86_64 1:1.0.1e-51.el7_2.5 openssl-devel.x86_64 1:1.0.1e-51.el7_2.5

依存性を更新しました: httpd.x86_64 0:2.4.6-40.el7.centos.1 httpd-tools.x86_64 0:2.4.6-40.el7.centos.1 openssl-libs.x86_64 1:1.0.1e-51.el7_2.5

完了しました! Checking for new version... Creating virtual environment... Installing Python packages... Installation succeeded. Requesting root privileges to run certbot... sudo CERTBOT_AUTO=./certbot-auto /home/astel/.local/share/letsencrypt/bin/letsencrypt certonly -a standalone -d astail.net [/code]

TUI メールとか入力する

[code lang=text] At least one of the (possibly) required ports is already taken.

IMPORTANT NOTES: - If you lose your account credentials, you can recover through e-mails sent to hogehoge@gmail.com. - 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. [asteltk2-234-26965 ] $ [/code]

でnginxをとめろと言われているのでとめる

[code lang=text] [asteltk2-234-26965 ] $ sudo service nginx stop Redirecting to /bin/systemctl stop nginx.service [asteltk2-234-26965 ] $ ./certbot-auto certonly -a standalone -d astail.net Checking for new version... Requesting root privileges to run certbot... sudo CERTBOT_AUTO=./certbot-auto /home/astel/.local/share/letsencrypt/bin/letsencrypt certonly -a standalone -d astail.net Failed authorization procedure. astail.net (tls-sni-01): urn:acme:error:connection :: The server could not connect to the client to verify the domain :: Failed to connect to host for DVSNI challenge

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

Domain: astail.net Type: connection Detail: Failed to connect to host for DVSNI challenge

To fix these errors, please make sure that your domain name was entered correctly and the DNS A 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. [/code]

またエラー

どうやら443ポートもあけておかないといけないらしい これはずっと httpでやってきた人はハマるとこかも

rootで作業した

[code lang=text] [roottk2-234-26965 ] # firewall-cmd --list-all --zone=public
public (default, active) interfaces: eth0 sources: services: dhcpv6-client http ssh ports: 9987/udp 10011/udp 30033/udp 10051/tcp masquerade: no forward-ports: icmp-blocks: rich rules:

[roottk2-234-26965 ] # firewall-cmd --get-services RH-Satellite-6 amanda-client bacula bacula-client cockpit dhcp dhcpv6 dhcpv6-client dns freeipa-ldap freeipa-ldaps freeipa-replication ftp high-availability http https imaps ipp ipp-client ipsec iscsi-target kerberos kpasswd ldap ldaps libvirt libvirt-tls mdns mountd ms-wbt mysql nfs ntp openvpn pmcd pmproxy pmwebapi pmwebapis pop3s postgresql proxy-dhcp radius rpc-bind rsyncd samba samba-client smtp ssh telnet tftp tftp-client transmission-client vdsm vnc-server wbem-https [roottk2-234-26965 ] #
[roottk2-234-26965 ] # [roottk2-234-26965 ] # [roottk2-234-26965 ] # firewall-cmd --add-service=https --zone=public --permanent success [roottk2-234-26965 ] # firewall-cmd --reload success [roottk2-234-26965 ] # firewall-cmd --list-all --zone=public
public (default, active) interfaces: eth0 sources: services: dhcpv6-client http https ssh ports: 9987/udp 10051/tcp 30033/udp 10011/udp masquerade: no forward-ports: icmp-blocks: rich rules:

[roottk2-234-26965 ] # ./certbot-auto certonly -a standalone \
-d astail.net Checking for new version... Requesting root privileges to run certbot... /root/.local/share/letsencrypt/bin/letsencrypt certonly -a standalone -d astail.net

IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at /etc/letsencrypt/live/astail.net/fullchain.pem. Your cert will expire on 2016-08-14. To obtain a new version of the certificate in the future, simply run Certbot again. - 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

[roottk2-234-26965 ] # service nginx start Redirecting to /bin/systemctl start nginx.service [/code]

でここらへんにシンボリックリンクがはられているファイルがあるのでnginxの設定でこれみるようにすればいいのかな

サーバ証明書(公開鍵) /etc/letsencrypt/live/ドメイン名/cert.pem 中間証明書 /etc/letsencrypt/live/ドメイン名/chain.pem サーバ証明書と中間証明書が結合されたファイル /etc/letsencrypt/live/ドメイン名/fullchain.pem 秘密鍵 /etc/letsencrypt/live/ドメイン名/privkey.pem

結構簡単