使用方法HTTPSファームのSSL証明書を暗号化しましょう

投稿日: 3 年 2019 月 XNUMX 日

概要

Let's Encryptは、オープンで自動化された認証局であり、 ACME (自動証明書管理環境)互換性のあるクライアントに無料のTLS / SSL証明書を提供するためのプロトコル。 これらの証明書は、Webサーバーとユーザー間の通信を暗号化するために使用できます。

このチュートリアルでは、認証局とZevenet統合がLet's Encryptとどのように連携するかについて簡単に説明し、次にZevenetが 証明書 (ACMEクライアント)Let'sEncryptインフラストラクチャと通信するため。

Zevenet Load Balancer 6.0.3以上のバージョンには、と呼ばれる小さなcertbotラッパーが含まれています。 letsencryptz Certbot webroot機能を使用するために、次の行はこのラッパーがどのように機能するかを説明しています。実稼働環境で機能させるためにこれらすべてを考慮に入れてください。

Let's Encryptの検証はどのように機能しますか?

簡単なwebroot機能の説明として、webrootプラグインはZevenetファイルパスに要求された各ドメインの一時ファイルを作成することによって機能します。 /usr/local/zevenet/app/letsencryptz/webroot/.well-known/acme-challenge/。 次に、Let's Encrypt検証サーバーはHTTP要求を行い、要求された各ドメインのDNSがletsencryptzラッパーを実行しているサーバーに解決され、検証用の一時ファイルにアクセスできることを検証します。次の図は実際の例を示しています。

Zevenetを暗号化しましょう

前の図では、Zevenet Load BalancerはパブリックIPアドレスを持つルーター/ファイアウォールの内側にあります。 185.79.20.147 (例として)HTTPおよびHTTPSトラフィックはVIP 192.168.101.31(例として)を使用して内部ロードバランサーに転送され、ロードバランサーは2の異なるファームで設定されます。

HTTPSファーム名 ウェブホスティング192.168.101.31:443。 この農場はWebホスティングを提供する責任があり、さまざまなWebサーバーがこれと共にインターネットに公開されています。 例えば、 test1.zevenet.es, test2.zevenet.es, test3.zevenet.es 特にこの仮想サービスで公開されているWebページをテストしています。
HTTPファーム名 Webホスティングリダイレクト192.168.101.31:80。 このファームはリダイレクト目的でのみ使用され、HTTPからHTTPSへのすべてのトラフィックを強制します。

前の図は、ドメインのSSL Let'sEncrypt証明書要求を示しています test1.zevenet.es 次のように:

1. 証明書要求は、ロードバランサー自体からLet'sEncryptインフラストラクチャに送信されます。
2. 暗号化して、新しいSSL証明書要求を検出しましょう test1.zevenet.es
3. 要求されたホストのDNSIP解決を暗号化して実行しましょう。 test1.zevenet.es 結果がパブリックIPアドレス、リクエストを開始したのと同じ発信元IPアドレスであることを確認します。
4. この時点で、アナウンスを暗号化しましょう。 letsencryptz スクリプト(webroot cerbot)を使ってファイルを作成する必要があります。 ハッシュ 公共の場で http://test1.zevenet.es/.well-know/acme-challenge/ (80 TCPポート)、ローカルディレクトリ /usr/local/zevenet/app/letsencryptz/webroot/.well-known/acme-challenge/。 次に、 letsencryptz このファイルをインターネット(ファーム)からアクセス可能にするために一時的なサービスを構成します。 Webホスティングリダイレクト この目的のために修正される予定です。 ファームがまだ構成されていない場合 letsencryptz このVIPとPortに一時的なものを作成します。
6. できるだけ早く letsencryptz 一時的なサービスの作成を確認し、Encryptサーバは一時検証ファイルが作成されていることを確認します。 ハッシュ 内容は正しいです。
7. 最後に、Let's Encryptサーバーは、作成済みの証明書を使用して最初のリクエストに応答します。 一般名 (CN) test1.zevenet.es.
8. Zevenetは既に作成された証明書をローカルパスに保存します / usr / local / zevenet / config / ファームに構成する準備ができました ウェブホスティング.

この段階で、新しいLet'sEncrypt証明書がHTTPS仮想サービスに使用されます。

オートメーションコマンドを暗号化しましょう

説明したように、 letsencryptz スクリプトは、作成、更新、破棄、一覧表示など、SSL証明書を管理するために必要なアクションを自動化します。 利用可能なコマンドの下を見つけてください。

root@zva6k:~# letsencryptz

letsencryptz description:

letsencryptz is a let's encrypt (certbot) wrapper with minimal parameters ready to manage Let's Encrypt certificates for ZEVENET https profiles. Take into account that this wrapper uses certbot webroot feature so the public Let's encrypt architecture requires to connect with a local Virtual IP and port (TCP 80 by default) in order to do a request validation for the requested domain, so as soon as the "obtain" param is used, this script will configure an HTTP farm which will be accessed by Let's encrypt for verification purpose, this configuration is done automatically by this script itself, only ensure that the used Virtual IP and HTTP port 80 is not used by any another load balanced farm, and also ensure that the DNS resolution for the requested domain is reachable from let's encrypt system.


usage:

/usr/local/zevenet/bin/letsencryptz <action> <commands>

action: --obtain | --destroy | --renew | --list | --listconf | --help

	--obtain: Request new Certificates using webroot cert-bot module.

		commands: --vip <Virtual IP> --farm <Farm Name> --domain <domain1> --domain <domain2> --domain <domainN> --test

        		--vip: The Virtual IP already configured were to publish a temporal web server, this will be connected by let's encrypt public servers to verify the certificate request. The Virtual IP has to be free on the 80 port in order to be bound by a local process, if it isn't free then use --farm instead.
        		--farm: The farm name which configures a temporal Service called "letsencryptz", if no farm is used a temporal farm called "letsencryptZevenet" will be configured in the selected Virtual IP.
        		--domain: The domain which requests the Certificate for, i.e. www.mycompany.com.
			--test: Optional parameter, if used the certificate is requested for test purpose.

	--destroy: Revoke and delete the indicated Certificate Name, the action is rejected if the given certificate is in use by a farm.
		
		commands: --certname <Certificate Name>
	       	
			--certname: Certificate Name, this value can be obtained from the action --list.

	--renew: Renew the certificates near to expiry, no commands needed
		
		commands: --test --forcerestart --vip <Virtual IP> --farm <Farm Name>
	       		--test:	Optional parameter, if used a dry-run is executed, the renew of the certificates is simulated. 
			--forcerestart: Optional parameter, if used the farms that are using the renewed certificates will be restarted in order to apply the changes.
                        --vip: The Virtual IP already configured where to publish a temporal web server, this will be connected by let's encrypt public servers to verify the certificate renew. The Virtual IP has to be free on the 80 port in order to be bound by a local process, if it isn't free then use --farm instead.
                        --farm: The farm name which configures a temporal Service called "letsencryptz", if no farm is used a temporal farm called "letsencryptZevenet" will be configured in the selected Virtual IP.

	--list: List all the local certificates managed by let's encrypt and the status, no commands needed.

	--listconf: List the Zevenet let's encrypt configuration module (check global.conf file), no commands needed. 

	--help: Obtain this help.


システムが未解決の依存関係を自動的にインストールするため、letsencryptzが最初に実行されるまでに時間がかかります。また、使用を開始する前に構成のレビューが行われます。Let's Encryptは、証明書に関連する電子メールアカウントまたは連絡先を要求します。この電子メールアカウントは、Let's Encryptシステムに対して実行されるすべてのアクションで使用されます。この電子メールは、メインの構成ファイルで構成できます。 /usr/local/zevenet/config/global.confディレクティブ $ le_email.

いくつかの使用例を以下に示します。

Zevenet Let'sEncrypt証明書の作成

このコマンドはドメインの新しい証明書を要求します test2.zevenet.es。 指定されたVIPが内部IPになることを考慮に入れてください。このトラフィックは、パブリックIPから内部IPにネイトする必要があります。 Let's Encryptがこのサービスに到達できない場合、リクエストは拒否されます。

root@zva6k:~# letsencryptz --obtain --vip 192.168.101.31 --domain test2.zevenet.es
WARNING: No farm name specified, a temporal farm with name letsencryptZevenet will be created in VIP 192.168.101.31 port 80.
Configuring farm for let's encrypt Certificate Name verification
Obtaining Certificate for domains test2.zevenet.es...
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator webroot, Installer None
Obtaining a new certificate
Non-standard path(s), might not work with crontab installed by your operating system package manager
Certificate Request for the domain(s) test2.zevenet.es OK
Created Certificate name test2.zevenet.es in PEM format ready for HTTPS profile
Destroying webroot configuration for the farm letsencryptZevenet
Deleting already configuration for letsencryptZevenet, service letsencryptz
Restarting farms using renewed certificates: 

Zevenet Let'sEncrypt証明書リスト

このコマンドを実行すると、Zevenet Let'sEncryptシステムによって管理されている現在の証明書が表示されます。

root@zva6k:~# letsencryptz --list
Listing all available certificates for the current configuration in config dir /usr/local/zevenet/config/letsencrypt/
Saving debug log to /var/log/letsencrypt/letsencrypt.log
	Certificate Name: test1.zevenet.es
	Domain(s): test1.zevenet.es
	Expiry Date: 2019-09-19 10:48:02+00:00 (VALID: 77 days)
	Pem Certificate file: /usr/local/zevenet/config/test1_zevenet_es.pem

	Certificate Name: test3.zevenet.es
	Domain(s): test3.zevenet.es
	Expiry Date: 2019-09-26 06:32:52+00:00 (VALID: 83 days)
	Pem Certificate file: /usr/local/zevenet/config/test3_zevenet_es.pem


フィールドを考慮に入れる 証明書名このフィールドはletsencryptzラッパーによって次のように認識されます。 –証明書名.

Zevenet Let'sEncrypt証明書の更新

前のコマンドは、すでに生成された証明書の更新が必要かどうかを確認します。この場合、更新は自動的に行われます。 更新された認定を受けている場合は、変更を適用するためにファームの再起動が必要になります。このオプションを使用してください。 –強制再起動 したい場合は letsencryptz 変更を適用するために必要なすべてのファームを再起動します。

root@zva6k:~# letsencryptz --renew --vip 192.168.101.31
Renewing all the required certificates
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Cert not yet due for renewal
Cert not yet due for renewal

Zevenet Let'sEncrypt証明書の削除

このコマンドは、与えられた証明書を取り消して削除します。 選択した証明書が現在任意のHTTPSファームで使用されていることをシステムが検出した場合、アクションは拒否されます。上の例では、証明書がファームで使用されているため削除アクションが拒否されます。 testhttps.

root@zva6k:~# letsencryptz --destroy --certname test3.zevenet.es
Revoking and deleting certificate(s) test3.zevenet.es for the current configuration...
This file can't be deleted because is used by the farm(s):  testhttps

証明書がファームから割り当て解除されるとすぐに、アクションが実行されます。

root@zva6k:~# letsencryptz --destroy --certname test3.zevenet.es
Revoking and deleting certificate(s) test3.zevenet.es for the current configuration...
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Deleted certificate(s) test3.zevenet.es in path /usr/local/zevenet/config/test3_zevenet_es.pem

Let'sEncrypt証明書をZevenetに移行する

Zevenetロードバランサーはのすべての設定ファイルを保存します 証明書 ローカルパス内 / usr / local / zevenet / config / letsencrypt /。 既存のcertbot設定ファイルを移動するには(デフォルトでは / etc / letsencrypt)別のサーバーからZevenetへの場合、サーバーにこの既存の構成ディレクトリのtarball(tar.gzファイル)を作成し、Zevenet Let'sEncrypt構成パスのコンテンツを解凍するだけです。 最後に、変数の変更を検討してください $ le_email ファイル内 global.conf 前回のリクエストで使用したものと同じEメールに送信します。

証明書クラスタリングのサポートを暗号化しましょう

Zevenet Let's Encryptプラグインは、ZevenetClusterサービスで完全にサポートされています。 Let's Encryptのすべてのアクションは、Zevenet Cluster Serviceによって複製された構成ファイルに保存されるため、 MASTER ノードはに複製されます。 SLAVE ノードは自動的に実行されますが、アクションは SLAVE Let's Encryptに関連するノードは、非同期化を回避するために破棄されます。

証明書の自動更新を暗号化しましょう

Zevenet Let's Encryptプラグインは、証明書の更新が必要かどうかを毎日チェックするように構成できます。システムが特定の証明書を自動的に更新し、それが一部のファームで使用されている場合、ファームは自動的に再起動されて適用されます。証明書の変更。

自動更新を設定するには、次の手順に従ってください。

次のcronファイルを作成してください。 /etc/cron.d/letsencryptz 以下の内容で

root@zva6k:~# cat /etc/cron.d/letsencryptz
00 00 * * *	root	/usr/local/zevenet/bin/letsencryptz --renew --forcerestart --vip 192.168.101.31

この構成では、更新チェックは毎日00:00(深夜)に実行されます。 また、VIP 192.168.101.31は、Let's EncryptSystemからの検証目的でポート80で使用されます。

リファレンス

この記事で使用されている参考文献は次のとおりです。

WebrootとCertbot
Let'sEncryptのしくみ

上の共有:

GNU Free Documentation Licenseの条項に基づくドキュメンテーション。

この記事は役に立ちましたか?

関連記事