Red Hat Training

A Red Hat training course is available for RHEL 8

3.4. OpenSSL を使用した TLS クライアント証明書の秘密鍵と CSR の作成

認証局 (CA) からの有効な TLS 証明書がある場合にのみ、TLS 暗号化通信チャネルを使用できます。証明書を取得するには、最初にクライアントの秘密鍵と証明書署名要求 (CSR) を作成する必要があります。

手順

  1. 次の例のように、クライアントシステムで秘密鍵を生成します。

    $ openssl genpkey -algorithm ec -pkeyopt ec_paramgen_curve:P-256 -out <client-private.key>
  2. オプション: 次の例のように、選択したテキストエディターを使用して、CSR の作成を簡素化する設定ファイルを準備します。

    $ vim <example_client.cnf>
    [client-cert]
    keyUsage = critical, digitalSignature, keyEncipherment
    extendedKeyUsage = clientAuth
    subjectAltName = @alt_name
    
    [req]
    distinguished_name = dn
    prompt = no
    
    [dn]
    CN = <client.example.com>
    
    [clnt_alt_name]
    email= <client@example.com>

    extendedKeyUsage = clientAuth オプションは、証明書の使用を制限します。

  3. 前に作成した秘密鍵を使用して CSR を作成します。

    $ openssl req -key <client-private.key> -config <example_client.cnf> -new -out <client-cert.csr>

    -config オプションを省略すると、req ユーティリティーは次のような追加情報の入力を求めます。

    You are about to be asked to enter information that will be incorporated
    into your certificate request.
    …
    Common Name (eg, your name or your server's hostname) []: <client.example.com>
    Email Address []: <client@example.com>

次のステップ

検証

  1. 次の例のように、証明書の中で人間が判読できる部分が要件と一致することを確認します。

    $ openssl x509 -text -noout -in <client-cert.crt>
    Certificate:
    …
                X509v3 Extended Key Usage:
                    TLS Web Client Authentication
                X509v3 Subject Alternative Name:
                    email:client@example.com
    …

関連情報

  • openssl (1)x509(1)genpkey (1)req (1)、および config (5) のman ページ