GNU/Linux >> Linux の 問題 >  >> Cent OS

EasyRSA(認証局)-CAをCentOS /RHEL8にインストールする

はじめに

Easy-RSAの概要

Easy-RSAは、X.509 PKI(公開鍵インフラストラクチャ)に加えて、PKI CA(認証局)を管理するためのユーティリティです。 PKIは、リモートピアを認証するために特定の権限を信頼するという概念に基づいています。 PKIの仕組みの詳細については、 Intro-To-PKIを参照してください。 ドキュメント。

プラットフォームに依存しないPOSIXシェルで記述されたコードで、さまざまなホストシステムで使用できます。Windowsの公式リリースには、Easy-RSAの使用に必要なプログラムもバンドルされています。シェルコードは、依存する外部プログラムの数を制限しようとします。暗号関連のタスクは、opensslを機能的なバックエンドとして使用します。

機能のハイライト

より注目すべきEasy-RSA機能の網羅的ではないリストは次のとおりです。

  • Easy-RSAは、それぞれが独自の独立した構成、ストレージディレクトリ、およびX.509拡張処理を備えた複数のPKIを管理できます。
  • 複数のサブジェクト名(X.509 DNフィールド)のフォーマットオプションがサポートされています。 VPNの場合、これはよりクリーンなcommonNameのみのセットアップを使用できることを意味します。
  • サポートされているすべてのプラットフォームで単一のバックエンドが使用され、豊富な機能から「取り残された」プラットフォームがないようにします。 Unixに似たもの(BSD、Linuxなど)とWindowsがすべてサポートされています。
  • Easy-RSAのX.509サポートには、CRL、CDP、keyUsage / eKu属性、および追加機能が含まれます。含まれているサポートは、高度な機能として変更または拡張できます。
  • インタラクティブで自動化された(バッチ)操作モード
  • 柔軟な構成:機能は、コマンドラインオプション、環境変数、構成ファイル、またはこれらの組み合わせによって有効にできます。
  • 組み込みのデフォルトにより、最初に構成ファイルを編集しなくてもEasy-RSAを使用できます。

つまり、EasyRSAは、ルート認証局を作成するための無料のオープンソースCLIユーティリティです。 、および中間CAと証明書失効リスト(CRL)を含む証明書を要求して署名します。

CentOS/RHELでパッケージを更新

新しいソフトウェアをインストールする前に、Linuxディストリビューションのソフトウェアパッケージを更新してください。

したがって、 dnfを実行します CentOS / Red HatEnterpriseLinuxのソフトウェアパッケージを更新するコマンド。

# dnf update -y

このインストールガイドで使用されているカーネルのバージョンを確認してください。

[root@rhel-pc ~]# uname -r
4.18.0-305.12.1.el8_4.x86_64
[root@rhel-pc ~]# 

Linuxディストリビューションのバージョンも確認してください。

[root@rhel-pc ~]# cat /etc/redhat-release
Red Hat Enterprise Linux release 8.4 (Ootpa)
[root@rhel-pc ~]# 

CentOS/RHELにEasyRSAをインストールする

EasyRSAの最新バージョンをダウンロードする wgetコマンドを使用します。

[root@rhel-pc mnt]# cd /mnt
[root@rhel-pc mnt]#  wget https://github.com/OpenVPN/easy-rsa/releases/download/v3.0.8/EasyRSA-3.0.8.tgz
--2021-08-15 23:10:26--  https://github.com/OpenVPN/easy-rsa/releases/download/v3.0.8/EasyRSA-3.0.8.tgz
Resolving github.com (github.com)... 140.82.121.3
Connecting to github.com (github.com)|140.82.121.3|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://github-releases.githubusercontent.com/4519663/2e0dee80-f7f3-11ea-9ba4-dc973db12175?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210815%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210815T210829Z&X-Amz-Expires=300&X-Amz-Signature=5199380d851889a82d52ae4950917b20c7717e387f0c6b62054969f554de8e04&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=4519663&response-content-disposition=attachment%3B%20filename%3DEasyRSA-3.0.8.tgz&response-content-type=application%2Foctet-stream [following]
--2021-08-15 23:10:28--  https://github-releases.githubusercontent.com/4519663/2e0dee80-f7f3-11ea-9ba4-dc973db12175?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210815%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210815T210829Z&X-Amz-Expires=300&X-Amz-Signature=5199380d851889a82d52ae4950917b20c7717e387f0c6b62054969f554de8e04&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=4519663&response-content-disposition=attachment%3B%20filename%3DEasyRSA-3.0.8.tgz&response-content-type=application%2Foctet-stream
Resolving github-releases.githubusercontent.com (github-releases.githubusercontent.com)... 185.199.111.154, 185.199.108.154, 185.199.109.154, ...
Connecting to github-releases.githubusercontent.com (github-releases.githubusercontent.com)|185.199.111.154|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 48907 (48K) [application/octet-stream]
Saving to: ‘EasyRSA-3.0.8.tgz’

EasyRSA-3.0.8.tgz                     100%[=======================================================================>]  47.76K  --.-KB/s    in 0.1s    

2021-08-15 23:10:29 (414 KB/s) - ‘EasyRSA-3.0.8.tgz’ saved [48907/48907]

[root@rhel-pc mnt]# 

tar を実行して、ダウンロードしたtarファイルを抽出します コマンド。

[root@rhel-pc mnt]# tar xfv EasyRSA-3.0.8.tgz 
EasyRSA-3.0.8/
EasyRSA-3.0.8/easyrsa
EasyRSA-3.0.8/openssl-easyrsa.cnf
EasyRSA-3.0.8/vars.example
EasyRSA-3.0.8/x509-types/
EasyRSA-3.0.8/gpl-2.0.txt
EasyRSA-3.0.8/mktemp.txt
EasyRSA-3.0.8/COPYING.md
EasyRSA-3.0.8/ChangeLog
EasyRSA-3.0.8/README.md
EasyRSA-3.0.8/README.quickstart.md
EasyRSA-3.0.8/doc/
EasyRSA-3.0.8/doc/EasyRSA-Advanced.md
EasyRSA-3.0.8/doc/EasyRSA-Readme.md
EasyRSA-3.0.8/doc/EasyRSA-Upgrade-Notes.md
EasyRSA-3.0.8/doc/Hacking.md
EasyRSA-3.0.8/doc/Intro-To-PKI.md
EasyRSA-3.0.8/x509-types/COMMON
EasyRSA-3.0.8/x509-types/ca
EasyRSA-3.0.8/x509-types/client
EasyRSA-3.0.8/x509-types/code-signing
EasyRSA-3.0.8/x509-types/email
EasyRSA-3.0.8/x509-types/kdc
EasyRSA-3.0.8/x509-types/server
EasyRSA-3.0.8/x509-types/serverClient
[root@rhel-pc mnt]# 

次に、抽出したディレクトリの名前を変更します。

[root@rhel-pc mnt]# mv EasyRSA-3.0.8 EasyRSA

PKIおよびCA証明書を生成する

以下のこのコマンドでこれを行うことができます:

[root@rhel-pc mnt]# cd EasyRSA/
[root@rhel-pc EasyRSA]# ./easyrsa init-pki

init-pki complete; you may now create a CA or requests.
Your newly created PKI dir is: /mnt/EasyRSA/pki


[root@rhel-pc EasyRSA]# 

次に、以下のコマンドを使用してサーバーおよびクライアントの証明書署名要求(CSR)に署名するために使用される認証局(CA)を生成します。

[root@rhel-pc EasyRSA]# ./easyrsa build-ca
Using SSL: openssl OpenSSL 1.1.1g FIPS  21 Apr 2020

Enter New CA Key Passphrase: 
Re-Enter New CA Key Passphrase: 
Generating RSA private key, 2048 bit long modulus (2 primes)
..................+++++
...........................................................................................................................................................+++++
e is 65537 (0x010001)
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Common Name (eg: your user, host, or server name) [Easy-RSA CA]:unixcop

CA creation complete and you may now import and sign cert requests.
Your new CA certificate file for publishing is at:
/mnt/EasyRSA/pki/ca.crt


[root@rhel-pc EasyRSA]# 

サーバーSSL証明書を生成する

したがって、以下のコマンドを使用してRSA秘密鍵とCSRを生成します。

[root@rhel-pc EasyRSA]# ./easyrsa gen-req easyrsa.unixcop.com nopass
Using SSL: openssl OpenSSL 1.1.1g FIPS  21 Apr 2020
Generating a RSA private key
............................................................................................................................................................................................+++++
..........+++++
writing new private key to 'https://1118798822.rsc.cdn77.org/mnt/EasyRSA/pki/easy-rsa-6230.db5Ie8/tmp.5R7sqs'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Common Name (eg: your user, host, or server name) [easyrsa.unixcop.com]:

Keypair and certificate request completed. Your files are:
req: /mnt/EasyRSA/pki/reqs/easyrsa.unixcop.com.req
key: /mnt/EasyRSA/pki/private/easyrsa.unixcop.com.key


[root@rhel-pc EasyRSA]# 

さらに、認証局(CA)の秘密鍵を使用してサーバーのCSRに署名します。

[root@rhel-pc EasyRSA]# ./easyrsa sign-req server easyrsa.unixcop.com
Using SSL: openssl OpenSSL 1.1.1g FIPS  21 Apr 2020


You are about to sign the following certificate.
Please check over the details shown below for accuracy. Note that this request
has not been cryptographically verified. Please be sure it came from a trusted
source or that you have verified the request checksum with the sender.

Request subject, to be signed as a server certificate for 825 days:

subject=
    commonName                = easyrsa.unixcop.com


Type the word 'yes' to continue, or any other input to abort.
  Confirm request details: yes
Using configuration from /mnt/EasyRSA/pki/easy-rsa-6260.UVEjyC/tmp.nTGkfr
Enter pass phrase for /mnt/EasyRSA/pki/private/ca.key:
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
commonName            :ASN.1 12:'easyrsa.unixcop.com'
Certificate is to be certified until Nov 18 21:18:53 2023 GMT (825 days)

Write out database with 1 new entries
Data Base Updated

Certificate created at: /mnt/EasyRSA/pki/issued/easyrsa.unixcop.com.crt


[root@rhel-pc EasyRSA]# 

SSL証明書に正常に署名しました。

また、SSL証明書が正しく生成されていることを確認するには、 opensslを実行します。 以下に示すコマンド。

[root@rhel-pc EasyRSA]#  openssl verify -CAfile pki/ca.crt /mnt/EasyRSA/pki/issued/easyrsa.unixcop.com.crt
/mnt/EasyRSA/pki/issued/easyrsa.unixcop.com.crt: OK
[root@rhel-pc EasyRSA]# 

(Diffie Hellman)キーを生成

そこで、 Diffieを生成します ヘルマン 鍵交換プロセスで使用される鍵。以下のコマンドを使用して生成します。

[root@rhel-pc EasyRSA]# ./easyrsa gen-dh
Using SSL: openssl OpenSSL 1.1.1g FIPS  21 Apr 2020
Generating DH parameters, 2048 bit long safe prime, generator 2
This is going to take a long time
......................................................................................................................................................................................................................................................................................................................................+..+...........................................+.....................+..........................................................................................+..........................................................................................................................................................................................................................................................................................................................................................................+........................................+....................................................................................................................+............................................................................................................................................................................................................+...................................+........................................................................................................................................................................................................................................................................+...........+......................................................................................................+...........................................................+..........................+...............................................................................................................................................+..................................................++*++*++*++*

DH parameters of size 2048 created at /mnt/EasyRSA/pki/dh.pem


[root@rhel-pc EasyRSA]# 

クライアントSSL証明書を生成する

クライアントのSSL証明書を生成します。

例に示すように、クライアントはqadry.unixcop.com

になります。
[root@rhel-pc EasyRSA]#  ./easyrsa gen-req qadry.unixcop.com nopass
Using SSL: openssl OpenSSL 1.1.1g FIPS  21 Apr 2020
Generating a RSA private key
..+++++
.............................+++++
writing new private key to 'https://1118798822.rsc.cdn77.org/mnt/EasyRSA/pki/easy-rsa-6458.r26VDM/tmp.fjd968'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Common Name (eg: your user, host, or server name) [qadry.unixcop.com]:

Keypair and certificate request completed. Your files are:
req: /mnt/EasyRSA/pki/reqs/qadry.unixcop.com.req
key: /mnt/EasyRSA/pki/private/qadry.unixcop.com.key


[root@rhel-pc EasyRSA]# 

また、以下に示すようにクライアントSSL証明書に署名することもできます。

[root@rhel-pc EasyRSA]# ./easyrsa sign-req client qadry.unixcop.com
Using SSL: openssl OpenSSL 1.1.1g FIPS  21 Apr 2020


You are about to sign the following certificate.
Please check over the details shown below for accuracy. Note that this request
has not been cryptographically verified. Please be sure it came from a trusted
source or that you have verified the request checksum with the sender.

Request subject, to be signed as a client certificate for 825 days:

subject=
    commonName                = qadry.unixcop.com


Type the word 'yes' to continue, or any other input to abort.
  Confirm request details: yes
Using configuration from /mnt/EasyRSA/pki/easy-rsa-6507.0eJrdy/tmp.sFYefJ
Enter pass phrase for /mnt/EasyRSA/pki/private/ca.key:
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
commonName            :ASN.1 12:'qadry.unixcop.com'
Certificate is to be certified until Nov 18 21:29:23 2023 GMT (825 days)

Write out database with 1 new entries
Data Base Updated

Certificate created at: /mnt/EasyRSA/pki/issued/qadry.unixcop.com.crt


[root@rhel-pc EasyRSA]# 

これで、クライアントSSL証明書が正常に生成されて署名されました。

また、/ etc / pki / ca-trust / source / branchs / に認証局(CA)証明書をコピーします Linuxクライアントの数を使用してCAを信頼できるCAリストに追加します。

結論

これで、CentOS / Red Hat Enterprise Linux 8にEasyRSAを正常にインストールできました。また、 easyrsa を使用して、サーバーとクライアントの認証局と署名付きSSL証明書を構成しました。 コマンド。


Cent OS
  1. RHEL 8 /CentOS8にSSLをインストールする方法

  2. RHEL 8 /CentOS8にphpMyAdminをインストールする方法

  3. CentOS 7 /RHEL7にWebminをインストールします

  1. RHEL 8 /CentOS8にP7Zipをインストールする方法

  2. RHEL 8 /CentOS8にntfs-3gをインストールする方法

  3. PHP-mbstringをRHEL8/CentOS8にインストールする方法

  1. RHEL 8 /CentOS8にphantomjsをインストールする方法

  2. DropboxをRHEL8/CentOS8にインストールする方法

  3. gnomeをRHEL8/CentOS8にインストールします