Previous Topic

Next Topic

Book Contents

Book Index

FTP - 証明書 - クライアント証明書の作成

SSL クライアント証明書を使用するには、個々のユーザーに証明書を発行する必要があり、通常は各ユーザーに 1 つずつ発行します。プロセスは次のとおりです。

証明書要求の作成

OpenSSL を使用する場合、証明書署名要求 (CSR) を作成するには、秘密 RSA キーの作成と、ユーザーの名前とその他の情報を含む証明書要求の作成の 2 つの手順があります。

最初にキーを作成します。ユーザーが入力する内容は太字で示されています。

例 1

C:\tmp>openssl genrsa -des3 -out clientcert.key 1024 Loading 'screen' into random state - done 
Generating RSA private key, 1024 bit long modulus
..............++++++ 
................++++++ 
e is 65537 (0x10001) 
Enter pass phrase for clientcert.key: (the password is not echoed) 
Verifying - Enter pass phrase for clientcert.key: 
C:\tmp>

この例では 1024 ビットキーを作成し、それを clientcert.key に格納しています。1024 ビットはセキュリティ上、問題ありませんが、セキュリティを向上させるために 2048 ビットキーを選択することもできます (ただしパフォーマンスは低下します)。

次に、CSR を作成します。

例 2

C:\tmp>openssl req -config \moveitdmz\util\openssl.conf -new -key clientcert.key -out clientcert.csr 
Enter pass phrase for clientcert.key: (enter the password given above) 
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) [US]:US 
State or Province Name (full name) [Some-State]:Wisconsin 
Locality Name (eg, city) []:Madison 
Organization Name (eg, company) [ACME Inc.]:Universal Exporters 
Organizational Unit Name (eg, section) []:Accounting 
Common Name (eg, fully qualified host name) []:Fred 
Email Address []:fred@univ-exporters.com 

Please enter the following 'extra' attributes 
to be sent with your certificate request 
A challenge password []: 
An optional company name []: 
C:\tmp>

この例では、フレッド (Fred) の証明書要求を作成します。通常は、オプションのチャレンジパスワードと企業名は空欄のままにします。証明書に署名する認証機関に clientcert.csr ファイルを送信する準備ができました。

証明書要求への署名

証明書要求を作成したら、署名を受けるために認証機関に送信する必要があります。次のような認証機関があります。

自己署名証明書の作成

CSR に自分で署名できるように自己署名証明書を作成するには:

例 3

C:\tmp>openssl req -config \moveitdmz\util\openssl.conf -x509 -days 365 -newkey rsa:1024 -keyout MyCAcert.key -out MyCAcert.cer 
Loading 'screen' into random state - done 
Generating a 1024 bit RSA private key 
.....++++++ 
....++++++ 
writing new private key to 'MyCAcert.key' 
Enter PEM pass phrase: (enter a new password that will be known only to the administrator) 
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) [US]:US 
State or Province Name (full name) [Some-State]:Wisconsin 
Locality Name (eg, city) []:Madison
Organization Name (eg, company) [ACME Inc.]:Universal Exporters 
Organizational Unit Name (eg, section) []:IT Dept 
Common Name (eg, fully qualified host name) []:UE IT Security 
Email Address []:ueitsec@univ-exporters.com 
C:\tmp>

これにより、365 日間有効な 1024 ビットの証明書が作成されます。この例では、証明書を作成する管理者は上記のクライアント証明書申請者と同じ組織に所属していますが、所属部署は異なります。キーは MyCAcert.key に、公開証明書は MyCAcert.cer に書き込まれます。MyCAcert.key ファイルとパスワードは必ず安全な場所に保存してください。

証明書要求に自分で署名する

自分で作成した、または他の発行元から入手した署名キーがあれば、CSR に署名できます。

例 4

C:\tmp>openssl x509 -req -in clientcert.csr -days 1000 -CA MyCAcert.cer -CAkey MyCAcert.key -CAcreateserial -out clientcert.cer 
Loading 'screen' into random state - done 
Signature ok 
subject=/C=US/ST=Wisconsin/L=Madison/O=Universal Exporters/OU=Accounting/CN=Fred/emailAddress=fred@univ-exporters.com 
Getting CA Private Key 
Enter pass phrase for MyCAcert.key: (enter the password of the CA cert) 
C:\tmp>

これによりユーザーの証明書署名要求を読み取り、それに署名して、clientcert.cer ファイルにクライアント証明書を作成します。この例では、証明書は 1,000 日間有効です。

この時点で、clientcert.cer はクライアント証明書の公開部分であり、clientcert.key は秘密部分です。一部のクライアントソフトウェア、特に Microsoft Windows では、クライアントで使用する前にこれらのファイルを別の形式に変換する必要があります。ユーザーの clientcert.key ファイルへのアクセス権がある場合 (自分で例 1 のような操作を行った場合など)、以下のようなコマンドを使用して、これら 2 つのファイルを Windows が必要とする 1 つのファイルの .pfx 形式に変換できます。

例 5

C:\tmp>openssl pkcs12 -export -in clientcert.cer -inkey clientcert.key -out clientcert.pfx 
Loading 'screen' into random state - done 
Enter pass phrase for clientcert.key: (enter the password created via "openssl genrsa" at the top) 
Enter Export Password: (enter a new password.It can be the same as the openssl genrsa password) 
Verifying - Enter Export Password: 
C:\tmp>

これで、clientcert.pfx ファイルには秘密キー部分と公開キー部分の両方が含まれました。ユーザーが自分の CSR を作成し、.key ファイルを管理者に提供していない場合、ユーザーはこの openssl pkcs12 コマンドを実行する必要があります。

ユーザーのコンピュータでクライアント証明書をインポートする

ユーザーのコンピュータで、クライアント証明書をコンピュータの証明書ストアにインポートする必要があります。オペレーティングシステムが Microsoft Windows である場合、コンピュータに clientcert.pfx をコピーして、以下の手順を実行する必要があります。

サーバーに CA 証明書をインストールする

自己署名 CA 証明書を作成した場合、サーバーにその証明書をインストールする必要があります。これにより、サーバーはこの CA 証明書の署名を持つクライアント証明書を信頼できるようになります (CA 証明書が主要な証明書ベンダーによって発行された場合、ベンダーの証明書は Windows 内に組み込まれるため、この手順は必要ありません)。

Windows の証明書ウィザードを実行して CA 証明書をインポートするには: