1.2.4.2. OpenSSL を使用したルート CA 証明書の作成

OpenSSL でルート CA 証明書を作成するには、以下の手順を実行します。

  1. 以下のコマンドを実行して、認証局 (CA) RSA 秘密鍵を生成します。

    openssl genrsa -out ca.key 4096
  2. CA キーを使用して自己署名の CA 証明書を生成します。以下のコマンドを実行します。

    openssl req -x509 -new -nodes -key ca.key -days 400 -out ca.crt -config req.cnf

    req.cnf ファイルは以下のファイルのようになります。

    [ req ]               # Main settings
    default_bits = 4096       # Default key size in bits.
    prompt = no               # Disables prompting for certificate values so the configuration file values are used.
    default_md = sha256       # Specifies the digest algorithm.
    distinguished_name = dn   # Specifies the section that includes the distinguished name information.
    x509_extensions = v3_ca   # The extentions to add to the self signed cert
    
    [ dn ]               # Distinguished name settings
    C = US                    # Country
    ST = North Carolina             # State or province
    L = Raleigh                # Locality
    O = Red Hat Open Shift     # Organization
    OU = Red Hat Advanced Container Management        # Organizational unit
    CN = www.redhat.com  # Common name.
    
    [ v3_ca ]          # x509v3 extensions
    basicConstraints=critical,CA:TRUE # Indicates whether the certificate is a CA certificate during the certificate chain verification process.