ラベル Let's Encrypt の投稿を表示しています。 すべての投稿を表示
ラベル Let's Encrypt の投稿を表示しています。 すべての投稿を表示

2016年10月14日金曜日

centos6のowncloudにlet's encryptを導入した話(サブドメイン(独自ip)運用)

実はこれの前に別の環境でletsencryptを動作させてみて成功していたのだけれども、
ログを残しておくのに失敗したので、別環境で再度やってみたというところ。
環境はcentos6。

https://blog.apar.jp/linux/3619/
に倣って

cd /home/myusername
git clone https://github.com/certbot/certbot 



./certbot-auto


うちだと7パッケージが新規インストールされた。
インストールしています:
 dialog             x86_64       1.1-9.20080819.1.el6       base          197 k
 libffi-devel       x86_64       3.0.5-3.2.el6              base           18 k
 python-tools       x86_64       2.6.6-66.el6_8             updates       871 k
依存性関連でのインストールをします。:
 tcl                x86_64       1:8.5.7-6.el6              base          1.9 M
 tix                x86_64       1:8.4.3-5.el6              base          252 k
 tk                 x86_64       1:8.5.7-5.el6              base          1.4 M
 tkinter            x86_64       2.6.6-66.el6_8             updates       258 k

最後に
完了しました!
Creating virtual environment...
./certbot-auto: line 583: virtualenv: コマンドが見つかりません

大丈夫か?
更に倣って進める。
今回はサブドメインだったので
./certbot-auto certonly --webroot \
-w /var/www/html -d subdomain.sampledomain.com -d www.subdomain.sampledomain.com \
-m admin@sampledomain.com \
--agree-tos
 ん?

パッケージ gcc-4.4.7-17.el6.x86_64 はインストール済みか最新バージョンです
パッケージ dialog-1.1-9.20080819.1.el6.x86_64 はインストール済みか最新バージョンです
パッケージ augeas-libs-1.0.0-10.el6.x86_64 はインストール済みか最新バージョンです
パッケージ openssl-1.0.1e-48.el6_8.3.x86_64 はインストール済みか最新バージョンです
パッケージ openssl-devel-1.0.1e-48.el6_8.3.x86_64 はインストール済みか最新バージョンです
パッケージ libffi-devel-3.0.5-3.2.el6.x86_64 はインストール済みか最新バージョンです
パッケージ redhat-rpm-config-9.0.3-51.el6.centos.noarch はインストール済みか最新バージョンです
パッケージ ca-certificates-2015.2.6-65.0.1.el6_7.noarch はインストール済みか最新バージョンです
パッケージ python-2.6.6-66.el6_8.x86_64 はインストール済みか最新バージョンです
パッケージ python-devel-2.6.6-66.el6_8.x86_64 はインストール済みか最新バージョンです
パッケージ python-virtualenv は利用できません。
パッケージ python-tools-2.6.6-66.el6_8.x86_64 はインストール済みか最新バージョンです
パッケージ python-pip は利用できません。
パッケージ 1:mod_ssl-2.2.15-54.el6.centos.x86_64 はインストール済みか最新バージョンです
 うーん・・・python-virtualenvとpython-pipが無いと言われる・・・。
 調べると
http://rriifftt.hatenablog.com/entry/2015/10/28/142043
epelか・・・。

epelを有効にして、再度
./certbot-auto
 すると

なんと青い疑似GUI画面。ええ、聞いてないよそんなの。

一回目の入力でドメインを入力。
2回目の入力でメールアドレス。
3回目は利用規約に同意。

すると「いやあ言われたバーチャルホスト、見つからなかったわー」
と言われたので、apacheの設定からやり直す。
VirtualHostでwww無しアリを作って、(何か嫌な感じだったので)
./certbot-auto certonly --webroot \
-w /var/www/html -d subdomain.sampledomain.com -d www.subdomain.sampledomain.com \
-m admin@sampledomain.com \
--agree-tos
で再実行。
 すると

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at
   /etc/letsencrypt/live/SUBDOMAIN.DOMAIN.COM/fullchain.pem.
   Your cert will expire on 2017-01-11. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot-auto
   again. To non-interactively renew *all* of your certificates, run
   "certbot-auto 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
ということで取得できた。

sslの設定をする。
http://weblabo.oscasierra.net/letsencrypt-2/
より

vi /etc/httpd/conf.d/ssl.conf


当該の鍵ファイル3点を編集。
SSLCertificateFile /etc/letsencrypt/live/[サーバーのドメイン]/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/[サーバーのドメイン]/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/[サーバーのドメイン]/chain.pem
自動更新は
crontab -u root -e

00 05 01 * * /usr/local/certbot/certbot-auto renew --force-renew && /bin/systemctl reload httpd
やっと普通に使えるようになった・・・。

他参考
https://letsencrypt.jp/usage/

http://weblabo.oscasierra.net/letsencrypt-2/

2015年12月9日水曜日

CentOS7でLet's Encryptを試して失敗した話

http://www.websec-room.com/2015/12/04/2380
にならう。

まんまだと上記を見れば良いじゃんになるので、失敗ログも含めて以下。


まずhttpd、openssl、mod_sslが入っているかどうか確認

[root@SERVERNAME letsencrypt]# rpm -qa|grep httpd

httpd-2.4.6-31.el7.centos.1.x86_64
httpd-tools-2.4.6-31.el7.centos.1.x86_64
[root@SERVERNAME letsencrypt]# rpm -qa|grep openssl
openssl-devel-1.0.1e-42.el7.9.x86_64
openssl-libs-1.0.1e-42.el7.9.x86_64
openssl-1.0.1e-42.el7.9.x86_64
[root@SERVERNAME letsencrypt]# rpm -qa|grep mod_ssl
mod_ssl-2.4.6-31.el7.centos.1.x86_64

インストールスクリプトの実行
[root@SERVERNAME letsencrypt]# ./letsencrypt-auto --help


Bootstrapping dependencies for RedHat-based OSes...
yum は /usr/bin/yum です
読み込んだプラグイン:fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.nara.wide.ad.jp
 * extras: ftp.nara.wide.ad.jp
 * updates: ftp.nara.wide.ad.jp
パッケージ python-2.7.5-18.el7_1.1.x86_64 はインストール済みか最新バージョンです
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ python-devel.x86_64 0:2.7.5-18.el7_1.1 を インストール
---> パッケージ python-virtualenv.noarch 0:1.10.1-2.el7 を インストール
--> 依存性解決を終了しました。

依存性を解決しました

================================================================================
 Package                アーキテクチャー
                                    バージョン               リポジトリー  容量
================================================================================
インストール中:
 python-devel           x86_64      2.7.5-18.el7_1.1         updates      389 k
 python-virtualenv      noarch      1.10.1-2.el7             base         1.2 M

トランザクションの要約
================================================================================
インストール  2 パッケージ

総ダウンロード容量: 1.6 M
インストール容量: 2.6 M
Downloading packages:
(1/2): python-devel-2.7.5-18.el7_1.1.x86_64.rpm            | 389 kB   00:00
(2/2): python-virtualenv-1.10.1-2.el7.noarch.rpm           | 1.2 MB   00:00
--------------------------------------------------------------------------------
合計                                               3.3 MB/s | 1.6 MB  00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  インストール中          : python-devel-2.7.5-18.el7_1.1.x86_64            1/2
  インストール中          : python-virtualenv-1.10.1-2.el7.noarch           2/2
  検証中                  : python-devel-2.7.5-18.el7_1.1.x86_64            1/2
  検証中                  : python-virtualenv-1.10.1-2.el7.noarch           2/2

インストール:
  python-devel.x86_64 0:2.7.5-18.el7_1.1
  python-virtualenv.noarch 0:1.10.1-2.el7

完了しました!
読み込んだプラグイン:fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.nara.wide.ad.jp
 * extras: ftp.nara.wide.ad.jp
 * updates: ftp.nara.wide.ad.jp
パッケージ git-1.8.3.1-4.el7.x86_64 はインストール済みか最新バージョンです
パッケージ gcc-4.8.3-9.el7.x86_64 はインストール済みか最新バージョンです
パッケージ redhat-rpm-config-9.1.0-68.el7.centos.noarch はインストール済みか最新バージョンです
パッケージ ca-certificates-2015.2.4-70.0.el7_1.noarch はインストール済みか最新バージョンです
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ augeas-libs.x86_64 0:1.1.0-17.el7 を インストール
---> パッケージ dialog.x86_64 0:1.2-4.20130523.el7 を インストール
---> パッケージ libffi-devel.x86_64 0:3.0.13-11.el7 を インストール
---> パッケージ openssl-devel.x86_64 1:1.0.1e-42.el7.9 を インストール
--> 依存性の処理をしています: krb5-devel(x86-64) のパッケージ: 1:openssl-devel-1.0.1e-42.el7.9.x86_64
--> トランザクションの確認を実行しています。
---> パッケージ krb5-devel.x86_64 0:1.12.2-15.el7_1 を インストール
--> 依存性の処理をしています: libverto-devel のパッケージ: krb5-devel-1.12.2-15.el7_1.x86_64
--> 依存性の処理をしています: libselinux-devel のパッケージ: krb5-devel-1.12.2-15.el7_1.x86_64
--> 依存性の処理をしています: libcom_err-devel のパッケージ: krb5-devel-1.12.2-15.el7_1.x86_64
--> 依存性の処理をしています: keyutils-libs-devel のパッケージ: krb5-devel-1.12.2-15.el7_1.x86_64
--> トランザクションの確認を実行しています。
---> パッケージ keyutils-libs-devel.x86_64 0:1.5.8-3.el7 を インストール
---> パッケージ libcom_err-devel.x86_64 0:1.42.9-7.el7 を インストール
---> パッケージ libselinux-devel.x86_64 0:2.2.2-6.el7 を インストール
--> 依存性の処理をしています: libsepol-devel >= 2.1.9-1 のパッケージ: libselinux-devel-2.2.2-6.el7.x86_64
--> 依存性の処理をしています: pkgconfig(libsepol) のパッケージ: libselinux-devel-2.2.2-6.el7.x86_64
---> パッケージ libverto-devel.x86_64 0:0.2.5-4.el7 を インストール
--> トランザクションの確認を実行しています。
---> パッケージ libsepol-devel.x86_64 0:2.1.9-3.el7 を インストール
--> 依存性解決を終了しました。

依存性を解決しました

================================================================================
 Package                 アーキテクチャー
                                    バージョン                リポジトリー
                                                                           容量
================================================================================
インストール中:
 augeas-libs             x86_64     1.1.0-17.el7              base        332 k
 dialog                  x86_64     1.2-4.20130523.el7        base        208 k
 libffi-devel            x86_64     3.0.13-11.el7             base         22 k
 openssl-devel           x86_64     1:1.0.1e-42.el7.9         updates     1.2 M
依存性関連でのインストールをします:
 keyutils-libs-devel     x86_64     1.5.8-3.el7               base         37 k
 krb5-devel              x86_64     1.12.2-15.el7_1           updates     641 k
 libcom_err-devel        x86_64     1.42.9-7.el7              base         30 k
 libselinux-devel        x86_64     2.2.2-6.el7               base        174 k
 libsepol-devel          x86_64     2.1.9-3.el7               base         71 k
 libverto-devel          x86_64     0.2.5-4.el7               base         12 k

トランザクションの要約
================================================================================
インストール  4 パッケージ (+6 個の依存関係のパッケージ)

総ダウンロード容量: 2.7 M
インストール容量: 5.6 M
Downloading packages:
(1/10): dialog-1.2-4.20130523.el7.x86_64.rpm               | 208 kB   00:00
(2/10): augeas-libs-1.1.0-17.el7.x86_64.rpm                | 332 kB   00:00
(3/10): keyutils-libs-devel-1.5.8-3.el7.x86_64.rpm         |  37 kB   00:00
(4/10): libcom_err-devel-1.42.9-7.el7.x86_64.rpm           |  30 kB   00:00
(5/10): libselinux-devel-2.2.2-6.el7.x86_64.rpm            | 174 kB   00:00
(6/10): libsepol-devel-2.1.9-3.el7.x86_64.rpm              |  71 kB   00:00
(7/10): libverto-devel-0.2.5-4.el7.x86_64.rpm              |  12 kB   00:00
(8/10): libffi-devel-3.0.13-11.el7.x86_64.rpm              |  22 kB   00:00
(9/10): krb5-devel-1.12.2-15.el7_1.x86_64.rpm              | 641 kB   00:00
(10/10): openssl-devel-1.0.1e-42.el7.9.x86_64.rpm          | 1.2 MB   00:00
--------------------------------------------------------------------------------
合計                                               2.8 MB/s | 2.7 MB  00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  インストール中          : libcom_err-devel-1.42.9-7.el7.x86_64           1/10
  インストール中          : keyutils-libs-devel-1.5.8-3.el7.x86_64         2/10
  インストール中          : libsepol-devel-2.1.9-3.el7.x86_64              3/10
  インストール中          : libselinux-devel-2.2.2-6.el7.x86_64            4/10
  インストール中          : libverto-devel-0.2.5-4.el7.x86_64              5/10
  インストール中          : krb5-devel-1.12.2-15.el7_1.x86_64              6/10
  インストール中          : 1:openssl-devel-1.0.1e-42.el7.9.x86_64         7/10
  インストール中          : dialog-1.2-4.20130523.el7.x86_64               8/10
  インストール中          : libffi-devel-3.0.13-11.el7.x86_64              9/10
  インストール中          : augeas-libs-1.1.0-17.el7.x86_64               10/10
  検証中                  : libselinux-devel-2.2.2-6.el7.x86_64            1/10
  検証中                  : libverto-devel-0.2.5-4.el7.x86_64              2/10
  検証中                  : libsepol-devel-2.1.9-3.el7.x86_64              3/10
  検証中                  : keyutils-libs-devel-1.5.8-3.el7.x86_64         4/10
  検証中                  : augeas-libs-1.1.0-17.el7.x86_64                5/10
  検証中                  : 1:openssl-devel-1.0.1e-42.el7.9.x86_64         6/10
  検証中                  : libffi-devel-3.0.13-11.el7.x86_64              7/10
  検証中                  : krb5-devel-1.12.2-15.el7_1.x86_64              8/10
  検証中                  : libcom_err-devel-1.42.9-7.el7.x86_64           9/10
  検証中                  : dialog-1.2-4.20130523.el7.x86_64              10/10

インストール:
  augeas-libs.x86_64 0:1.1.0-17.el7     dialog.x86_64 0:1.2-4.20130523.el7
  libffi-devel.x86_64 0:3.0.13-11.el7   openssl-devel.x86_64 1:1.0.1e-42.el7.9

依存性関連をインストールしました:
  keyutils-libs-devel.x86_64 0:1.5.8-3.el7
  krb5-devel.x86_64 0:1.12.2-15.el7_1
  libcom_err-devel.x86_64 0:1.42.9-7.el7
  libselinux-devel.x86_64 0:2.2.2-6.el7
  libsepol-devel.x86_64 0:2.1.9-3.el7
  libverto-devel.x86_64 0:0.2.5-4.el7

完了しました!
Creating virtual environment...
Updating letsencrypt and virtual environment dependencies...../root/.local/share/letsencrypt/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
./root/.local/share/letsencrypt/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
.
Running with virtualenv: /root/.local/share/letsencrypt/bin/letsencrypt --help

  letsencrypt [SUBCOMMAND] [options] [-d domain] [-d domain] ...

The Let's Encrypt agent can obtain and install HTTPS/TLS/SSL certificates.  By
default, it will attempt to use a webserver both for obtaining and installing
the cert. Major SUBCOMMANDS are:

  (default) run        Obtain & install a cert in your current webserver
  certonly             Obtain cert, but do not install it (aka "auth")
  install              Install a previously obtained cert in a server
  revoke               Revoke a previously obtained certificate
  rollback             Rollback server configuration changes made during install
  config_changes       Show changes made to server config during installation
  plugins              Display information about installed plugins

Choice of server plugins for obtaining and installing cert:

  --apache          Use the Apache plugin for authentication & installation
  --standalone      Run a standalone webserver for authentication
  (nginx support is experimental, buggy, and not installed by default)
  --webroot         Place files in a server's webroot folder for authentication

OR use different plugins to obtain (authenticate) the cert and then install it:

  --authenticator standalone --installer apache

More detailed help:

  -h, --help [topic]    print this message, or detailed help on a topic;
                        the available topics are:

   all, automation, paths, security, testing, or any of the subcommands or
   plugins (certonly, install, nginx, apache, standalone, webroot, etc)

インストール出来たのか・・・?
取り敢えず出来たことにして、先に進む。

./letsencrypt-auto --apache



で、httpdを止めて--debug付きで実行してみると・・・

[root@SERVERNAME letsencrypt]# service httpd stop                                Redirecting to /bin/systemctl stop  httpd.service
[root@SERVERNAME letsencrypt]# ./letsencrypt-auto certonly --standalone -d MY-DOMAIN-NAME.DOMAIN --debug

Updating letsencrypt and virtual environment dependencies.......
Running with virtualenv: /root/.local/share/letsencrypt/bin/letsencrypt certonly --standalone -d MY-DOMAIN-NAME.DOMAIN --debug
Traceback (most recent call last):
  File "/root/.local/share/letsencrypt/bin/letsencrypt", line 11, in
    sys.exit(main())
  File "/root/.local/share/letsencrypt/lib/python2.7/site-packages/letsencrypt/cli.py", line 1283, in main
    return args.func(args, config, plugins)
  File "/root/.local/share/letsencrypt/lib/python2.7/site-packages/letsencrypt/cli.py", line 512, in obtain_cert
    _auth_from_domains(le_client, config, domains)
  File "/root/.local/share/letsencrypt/lib/python2.7/site-packages/letsencrypt/cli.py", line 336, in _auth_from_domains
    lineage = le_client.obtain_and_enroll_certificate(domains)
  File "/root/.local/share/letsencrypt/lib/python2.7/site-packages/letsencrypt/client.py", line 283, in obtain_and_enroll_certificate
    certr, chain, key, _ = self.obtain_certificate(domains)
  File "/root/.local/share/letsencrypt/lib/python2.7/site-packages/letsencrypt/client.py", line 266, in obtain_certificate
    return self._obtain_certificate(domains, csr) + (key, csr)
  File "/root/.local/share/letsencrypt/lib/python2.7/site-packages/letsencrypt/client.py", line 224, in _obtain_certificate
    authzr = self.auth_handler.get_authorizations(domains)
  File "/root/.local/share/letsencrypt/lib/python2.7/site-packages/letsencrypt/auth_handler.py", line 84, in get_authorizations
    self._respond(cont_resp, dv_resp, best_effort)
  File "/root/.local/share/letsencrypt/lib/python2.7/site-packages/letsencrypt/auth_handler.py", line 142, in _respond
    self._poll_challenges(chall_update, best_effort)
  File "/root/.local/share/letsencrypt/lib/python2.7/site-packages/letsencrypt/auth_handler.py", line 204, in _poll_challenges
    raise errors.FailedChallenges(all_failed_achalls)
FailedChallenges: Failed authorization procedure. MY-DOMAIN-NAME.DOMAIN (tls-sni-01): urn:acme:error:connection :: The server could not connect to the client for DV :: Failed to connect to host for DVSNI challenge


IMPORTANT NOTES:
 - The following 'urn:acme:error:connection' errors were reported by
   the server:

   Domains: MY-DOMAIN-NAME.DOMAIN
   Error: The server could not connect to the client for DV


うん、エラーで止まった。
httpdを有効にしてスタートすると、メールアドレス入力までは行き着くが、80番を聞いてるから落として再実行しろとのたまう。
現状ここまで。


追記
成功したのは
http://roserogue.blogspot.jp/2016/10/centos-owncloud-lets-encrypt.html
で。
というか、これもある意味成功していたのだけれども、ルータとサーバでポートを空けていなかったから、letsencrypt側から確認出来なかった、というのが原因でエラーを吐いていた。
あと、あるあるミスのselinux。