AWS Client VPNで使用するサーバ証明書とクライアント証明書を作成する - kin-kin/memo GitHub Wiki
AWS Client VPNで使用するサーバ証明書とクライアント証明書を作成する
1. ローカルコンピュータに OpenVPN Easy-RSA レポジトリのクローンを作成。
$ git clone https://github.com/OpenVPN/easy-rsa.git
2. 新しい PKI 環境を初期化、新しい認証機関 (CA) を構築。
$ cd easy-rsa/easyrsa3
$ export EASYRSA_CERT_EXPIRE=3650 (必要であれば証明書の有効日数を変更)
$ ./easyrsa init-pki
$ ./easyrsa build-ca nopass
Using SSL: openssl OpenSSL 1.0.2k-fips 26 Jan 2017
Generating RSA private key, 2048 bit long modulus
..................................................................................+++
.......+++
e is 65537 (0x10001)
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]:(任意の名前)
CA creation complete and you may now import and sign cert requests.
Your new CA certificate file for publishing is at:
/home/ec2-user/tmp/easy-rsa/easyrsa3/pki/ca.crt
3. サーバー証明書とキーを生成。
$ ./easyrsa build-server-full (サーバのドメイン名) nopass
Using SSL: openssl OpenSSL 1.0.2k-fips 26 Jan 2017
Generating a 2048 bit RSA private key
..............................................................................+++
..+++
writing new private key to '/home/ec2-user/tmp/easy-rsa/easyrsa3/pki/easy-rsa-3678.nT16ou/tmp.41vSd7'
-----
Using configuration from /home/ec2-user/tmp/easy-rsa/easyrsa3/pki/easy-rsa-3678.nT16ou/tmp.gw6hKs
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
commonName :ASN.1 12:'server'
Certificate is to be certified until Jul 30 03:18:07 2022 GMT (825 days)
Write out database with 1 new entries
Data Base Updated
4. クライアント証明書とキーを生成。
$ ./easyrsa build-client-full (クライアントのドメイン名) nopass
Using SSL: openssl OpenSSL 1.0.2k-fips 26 Jan 2017
Generating a 2048 bit RSA private key
..........+++
...+++
writing new private key to '/home/ec2-user/tmp/easy-rsa/easyrsa3/pki/easy-rsa-3776.MoS6Um/tmp.zblqed'
-----
Using configuration from /home/ec2-user/tmp/easy-rsa/easyrsa3/pki/easy-rsa-3776.MoS6Um/tmp.LGCI5O
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
commonName :ASN.1 12:'client1.domain.tld'
Certificate is to be certified until Jul 30 03:21:25 2022 GMT (825 days)
Write out database with 1 new entries
Data Base Updated
5. 生成した証明書を取得。
CA証明書:pki/ca.crt
サーバ証明書:pki/issued/サーバのドメイン名.crt
サーバ秘密鍵:pki/private/サーバのドメイン名.key
クライアント証明書:pki/issued/クライアントのドメイン名.crt
クライアント秘密鍵:pki/private/クライアントのドメイン名.key
6. AWSマネジメントコンソールにサインイン。 7. サービスからCertificate Managerを選択。 8. [証明書のインポート] ボタンを押下。 9. 「証明書本文」にサーバ証明書の内容、「証明書のプライベートキー」にサーバ秘密鍵の内容、「証明書チェーン」にCA証明書の内容を貼り付け、[次へ] ボタンを押下。 10. タグを追加、[レビューとインポート] ボタンを押下。 11. [インポート] ボタンを押下。 12. 手順9~11と同様にクライアント証明書・クライアント秘密鍵・CA証明書をインポート。
(参考)