2.5.2. 独自の CA の設定
実行するサブステップ
このセクションでは、独自のプライベート CA を設定する方法について説明します。実際の展開用に CA を設定する前に、「プライベート認証局」 の追加の注意事項をお読みください。
独自の CA を設定するには、以下の手順を実行します。
bin ディレクトリーを PATH に追加します。
安全な CA ホストで、OpenSSL bin
ディレクトリーをパスに追加します。
Windows
> set PATH=OpenSSLDir\bin;%PATH%
UNIX
% PATH=OpenSSLDir/bin:$PATH; export PATH
この手順により、コマンドラインから openssl
ユーティリティーを利用できるようになります。
CA ディレクトリー階層の作成
新規 CA を保持する新規ディレクトリー X509CA を作成します。このディレクトリーは、CA に関連付けられたすべてのファイルを保持するために使用されます。X509CA ディレクトリーの下に、以下のディレクトリーの階層を作成します。
|
|
|
|
openssl.cnf ファイルのコピーと編集
OpenSSL インストールから X509CA ディレクトリーにサンプル openssl.cnf
をコピーします。
openssl.cnf
を編集して、X509CA ディレクトリーのディレクトリー構造を反映し、新しい CA によって使用されるファイルを特定します。
openssl.cnf
ファイルの [CA_default]
セクションを編集して、以下のようにします。
#############################################################
[ CA_default ]
dir = X509CA # Where CA files are kept
certs = $dir/certs # Where issued certs are kept
crl_dir = $dir/crl # Where the issued crl are kept
database = $dir/index.txt # Database index file
new_certs_dir = $dir/newcerts # Default place for new certs
certificate = $dir/ca/new_ca.pem # The CA certificate
serial = $dir/serial # The current serial number
crl = $dir/crl.pem # The current CRL
private_key = $dir/ca/new_ca_pk.pem # The private key
RANDFILE = $dir/ca/.rand
# Private random number file
x509_extensions = usr_cert # The extensions to add to the cert
...
この段階で、OpenSSL 設定の他の詳細を編集することもできます。詳細は、http://www.openssl.org/docs/ を参照してください。
CA データベースの初期化
X509CA ディレクトリーで、serial
と index.txt
の 2 つのファイルを初期化します。
Windows
Windows で serial
ファイルを初期化するには、以下のコマンドを入力します。
> echo 01 > serial
Windows で空のファイル index.txt
を作成するには、以下のように X509CA ディレクトリーのコマンドラインで Windows Notepad を起動します。
> notepad index.txt
ダイアログボックスにCannot find the text.txt file. Do you want to create a new file?
というテキストが表示されたら、Yes をクリックして Notepad を閉じます。
UNIX
UNIX の serial
ファイルおよび index.txt
ファイルを初期化するには、以下のコマンドを入力します。
% echo "01" > serial % touch index.txt
これらのファイルは、証明書ファイルのデータベースを維持するために CA によって使用されます。
index.txt
ファイルは、最初は完全に空でなければならず、空白も含んではいけません。
自己署名 CA 証明書および秘密鍵の作成
以下のコマンドを使用して、新しい自己署名 CA 証明書と秘密鍵を作成します。
openssl req -x509 -new -config X509CA/openssl.cnf -days 365 -out X509CA/ca/new_ca.pem -keyout X509CA/ca/new_ca_pk.pem
このコマンドは、CA 秘密鍵のパスフレーズと、CA 識別名の詳細を要求します。以下に例を示します。
Using configuration from X509CA/openssl.cnf
Generating a 512 bit RSA private key
....++
.++
writing new private key to 'new_ca_pk.pem'
Enter PEM pass phrase:
Verifying password - 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) []:IE
State or Province Name (full name) []:Co. Dublin
Locality Name (eg, city) []:Dublin
Organization Name (eg, company) []:Red Hat
Organizational Unit Name (eg, section) []:Finance
Common Name (eg, YOUR name) []:Gordon Brown
Email Address []:gbrown@redhat.com
CA のセキュリティーは、秘密鍵ファイルと、この手順で使用する秘密鍵のパスフレーズによって異なります。
CA 証明書と秘密鍵 (new_ca.pem
および new_ca_pk.pem
) のファイル名と場所が、openssl.cnf
で指定した値と同じであることを確認してください (前述の手順を参照)。
これで、CA で証明書に署名する準備が整いました。