2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ACMのPrivate認証局を試してみる

Posted at

###はじめに

ACMのプライベート認証局作成の手順メモです。

上位CAとなる認証局の作成 ※EC2インスタンスなどで実施
ACMでPvivate CA作成
ACMでPrvate証明書作成

###上位CAとなる認証局を作成
Amazon Linuxで作成します。opensslの設定ファイルを編集します。
作成するサーバ証明書の期限が1年なのでdefault_daysを1年より長くする。
[ v3_ca ]のbasicConstraintsをcritical,CA:trueに設定する。

[root@ip-10-0-1-127 ~]# diff /etc/pki/tls/openssl.cnf /etc/pki/tls/openssl.cnf.bk
73c73
< default_days	= 3650			# how long to certify for
---
> default_days	= 365			# how long to certify for
223c223
< basicConstraints = critical,CA:true #[ v3_ca ]
---
> basicConstraints = CA:FALSE

criticalがないと証明書のインポート時に以下のエラーがでて失敗します。
image.png

ルートCAを作成します。

# /etc/pki/tls/misc/CA -newca
CA certificate filename (or enter to create)

Making CA certificate ...
Generating a 2048 bit RSA private key
.......................+++
..+++
writing new private key to '/etc/pki/CA/private/./cakey.pem'
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:
-----
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.
-----
Country Name (2 letter code) [XX]:JP
State or Province Name (full name) []:Tokyo
Locality Name (eg, city) [Default City]:Meguro-ku
Organization Name (eg, company) [Default Company Ltd]:Company
Organizational Unit Name (eg, section) []:section
Common Name (eg, your name or your server's hostname) []:private-root-ca
Email Address []:

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
Using configuration from /etc/pki/tls/openssl.cnf
Enter pass phrase for /etc/pki/CA/private/./cakey.pem:
Check that the request matches the signature
Signature ok
Certificate Details:
        Serial Number:
            c2:0a:82:6f:c7:22:be:0c
        Validity
            Not Before: Jan  1 16:18:09 2019 GMT
            Not After : Dec 31 16:18:09 2021 GMT
        Subject:
            countryName               = JP
            stateOrProvinceName       = Tokyo
            organizationName          = Company
            organizationalUnitName    = section
            commonName                = private-root-ca
        X509v3 extensions:
            X509v3 Subject Key Identifier: 
                30:2A:9A:EF:6D:FC:29:40:16:75:D2:0F:AB:A3:F6:5A:90:12:B7:30
            X509v3 Authority Key Identifier: 
                keyid:30:2A:9A:EF:6D:FC:29:40:16:75:D2:0F:AB:A3:F6:5A:90:12:B7:30

            X509v3 Basic Constraints: critical
                CA:TRUE
Certificate is to be certified until Dec 31 16:18:09 2021 GMT (1095 days)

Write out database with 1 new entries
Data Base Updated

###プライベートCAを作成する
ACMのダッシュボードでCreate CAをクリックする。
image.png

下位CAを選択してNext。
image.png

ルートCAの設定値を記入する。
image.png

Next
image.png

Next
image.png

Confirm and create。
image.png

###上位CAで下位CAの証明書を署名してインポート
image.png

Import CA certificateをクリック。
image.png

CSRファイルをダウンロードする。
image.png

###証明書を署名

CSRをリネームする。

mv /Downloads/CSR.pem newreq.pem 

証明書を署名する。

# /etc/pki/tls/misc/CA -signCA
Using configuration from /etc/pki/tls/openssl.cnf
Enter pass phrase for /etc/pki/CA/private/cakey.pem:
Check that the request matches the signature
Signature ok
Certificate Details:
        Serial Number:
            c2:0a:82:6f:c7:22:be:0d
        Validity
            Not Before: Jan  1 16:19:03 2019 GMT
            Not After : Dec 29 16:19:03 2028 GMT
        Subject:
            countryName               = JP
            stateOrProvinceName       = Tokyo
            localityName              = Meguro-ku
            organizationName          = Company
            organizationalUnitName    = section
            commonName                = private-ca
        X509v3 extensions:
            X509v3 Subject Key Identifier: 
                36:B1:80:7C:B0:42:77:67:1A:9A:15:D7:7C:66:C0:68:86:7A:95:93
            X509v3 Authority Key Identifier: 
                keyid:30:2A:9A:EF:6D:FC:29:40:16:75:D2:0F:AB:A3:F6:5A:90:12:B7:30

            X509v3 Basic Constraints: critical
                CA:TRUE
Certificate is to be certified until Dec 29 16:19:03 2028 GMT (3650 days)
Sign the certificate? [y/n]:y


1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated
Signed CA certificate is in newcert.pem

署名した証明書(newcert.pem)とCA証明書(cacert.pem)をコピペする。以下の箇所。

-----BEGIN CERTIFICATE REQUEST-----
略)
-----END CERTIFICATE REQUEST-----

image.png

Confirm and importをクリックする。
image.png

image.png

###private証明書の発行
Request a certificateをクリックする。
image.png

プライベート証明書を選択する。
image.png

CAとして作成した下位CAを選択する。
image.png

image.png

Comfirm and requestをクリックする。
image.png

##お約束
投稿内容は私個人の意見であり、所属企業・部門見解を代表するものではありません。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?