クライアント、サーバーおよび信頼できるチェーン証明書の作成

クイックスタートのこの部分は、分散パスを介して2つのデプロイメントを接続するための前提条件です。

本番環境では、証明書はDigiCertなどのデジタル認証局によって提供されます。ただし、テスト環境では、このクイックスタートの手順を使用して証明書を生成できます。

ノート:

最新のJDKがインストールされ、JAVA_HOME環境変数が設定されていることを確認します。これは、orapkiユーティリティの実行に必要です。

このトピックのステップに従って、ソース・デプロイメントおよびターゲット・デプロイメントにサーバー、クライアント・チェーンおよび信頼できる証明書チェーンを作成します。

ソース・デプロイメント:

  1. rootCA証明書を作成します。
    1. 次のような構成ファイルを使用して、rootCA.cfgを作成します:

      [ req ]
      default_bits = 4096
      default_md = sha512
      prompt = no
      encrypt_key = no
      distinguished_name = req_distinguished_name
      req_extensions = v3_req
      x509_extensions = v3_ca
      x509_extensions = usr_cert
      [ req_distinguished_name ]
      commonName = "gg-Root"
      [ v3_req ]
      basicConstraints=CA:TRUE
      [ v3_ca ]
      basicConstraints=CA:TRUE
      [ usr_cert ]
      basicConstraints=CA:TRUE
      [ my_extensions ]
      
    2. 次のコマンドを使用して、rootCA証明書を作成します:
      openssl req -x509 -newkey rsa:4096 -keyout rootCA.key -out rootCA.cert -days 73000 -nodes -config
      rootCA.cfg
  2. サーバー証明書を作成します。
    1. serverディレクトリを作成し、このディレクトリに移動します。
      mkdir server
      cd server
    2. サーバー構成ファイルserver.cfgを表示します。
      [ req ]
      default_bits = 4096
      default_md = sha512
      prompt = no
      encrypt_key = no
      distinguished_name = req_distinguished_name
      [ req_distinguished_name ]
      commonName = "west.oracle.com"
      [ my_extensions ]
      
    3. サーバー証明書を作成します。
      openssl req -new -newkey rsa:2048 -nodes -keyout servery -out servery -config server.cfg
      
      openssl x509 -req -days 73000 -in server.csr -CA ../rootCA.cert -CAkey ../rootCA.key -CAcreateserial -out
      server.cert
  3. サーバーの空の自動ログインOracleウォレットを作成します。
    orapki wallet create -wallet ../server -auto_login

    プロンプトが表示されたら、ウォレットにログインするためのパスワードを入力します。

  4. サーバー証明書および信頼できる証明書(rootCA)チェーン詳細を使用して、pkcs#12ファイルを作成します。
    openssl pkcs12 -export -out server.p12 -inkey server.key -in server.cert -chain -CAfile ../rootCA.cert

    プロンプトが表示されたら、パスワードを入力します。

  5. pkcs#12ファイルを自動ログイン・ウォレットにインポートします。
    orapki wallet import_pkcs12 -wallet ../server -pkcs12file ./server.p12

    必要な場合にはパスワードを入力します。

  6. ウォレットの内容を確認します。

    orapki wallet display -wallet ../server/ -complete

    ノート:

    最新のJDKがシステムにインストールされていることを確認します。
  7. クライアント証明書を含むクライアント構成ファイルおよびクライアント・ウォレットを作成します。
    1. ディレクトリ・クライアントを作成します。
      cd ..
      mkdir client
      cd client
      cat >client.cfg <<EOF
      クライアント構成ファイル(client.cfg):
      [ req ]
      default_bits = 4096
      default_md = sha512
      prompt = no
      encrypt_key = no
      distinguished_name = req_distinguished_name
      [ req_distinguished_name ]
      commonName = "client_src"
      [ my_extensions ]
      EOF
    2. 次のコード・スニペットに示すステップを使用して、クライアント証明書を作成します。

      openssl req -new -newkey rsa:2048 -nodes -keyout client.key -out client.csr -config client.cfg
      openssl x509 -req -days 73000 -in client.csr -CA ../rootCA.cert -CAkey ../rootCA.key -CAcreateserial -out
      client.cert
      
    3. クライアントの空の自動ログイン・ウォレットを作成します。
      orapki wallet create -wallet ../client -auto_login
      
    4. クライアント証明書および信頼できる証明書(rootCA)チェーン詳細を使用して、pkcs#12ファイルを作成します。

      openssl pkcs12 -export -out client.p12 -inkey ./client.key -in ./client.cert -chain -CAfile ../rootCA.cert
    5. pkcs#12ファイルを自動ログイン・ウォレットにインポートします。
      orapki wallet import_pkcs12 -wallet ../client -pkcs12file ./client.p12
    6. クライアント・ウォレットの内容を確認します。

      orapki wallet display -wallet ../client/ -complete

ターゲット・デプロイメント

ソース・サーバーおよびクライアント証明書の生成に使用したように、同じステップを繰り返してターゲット・サーバーおよびクライアント証明書を作成します。
  1. 以前に作成したrootCA証明書をターゲット・デプロイメントにコピーします。

  2. 次のコード・スニペットに示すように、ターゲット・サーバー証明書を生成します:

    ## a. Make target directory 
    cd ..
    mkdir target
    cd target
    
    ## b. Create target configuration file
    cat > target.cfg << EOF
    
    ## c. Target Configuration File (target.cfg)
    [ req ]
    default_bits = 4096
    default_md = sha512
    prompt = no
    encrypt_key = no
    distinguished_name = req_distinguished_name
    [ req_distinguished_name ]
    commonName = "east.oracle.com"
    [ my_extensions ]
    EOF
    
    ## d. Create the certificate for the target server
    openssl req -new -newkey rsa:2048 -nodes -keyout target.key -out target.csr -config target.cfg
    openssl x509 -req -days 73000 -in target.csr -CA ../rootCA.cert -CAkey ../rootCA.key -CAcreateserial -out
    target.cert
    
    ## e. Create an empty auto-login wallet for the target certificate
    orapki wallet create -wallet ../target -auto_login
    
    ## f. Create a pkcs#12 file using the target certificate and trusted certificate chain details
    openssl pkcs12 -export -out target.p12 -inkey ./target.key -in ./target.cert -chain -CAfile ../rootCA.cert
    
    ## g. Import the pkcs#12 file into the auto-login wallet
    orapki wallet import_pkcs12 -wallet ../target -pkcs12file ./target.p12
    
    ## h. Review the content of the wallet
    orapki wallet display -wallet ../target/ -complete
  3. ターゲット・クライアント証明書を生成します:
    ## make directory 
    cd ..
    mkdir client
    cd client
    cat >client.cfg <<EOF
    ## client configuration file 
    [ req ]
    default_bits = 4096
    default_md = sha512
    prompt = no
    encrypt_key = no
    distinguished_name = req_distinguished_name
    [ req_distinguished_name ]
    commonName = "client_trg"
    [ my_extensions ]
    EOF
    ##command to generate the client certificate
    openssl req -new -newkey rsa:2048 -nodes -keyout client.key -out client.csr -config client.cfg
    openssl x509 -req -days 73000 -in client.csr -CA ../rootCA.cert -CAkey ../rootCA.key -CAcreateserial -out
    client.cert
    
    ## Create an empty auto-login wallet for the target certificate
    orapki wallet create -wallet ../client -auto_login
    
    ## Create a pkcs#12 file using the target certificate and trusted certificate chain details.
    openssl pkcs12 -export -out client.p12 -inkey ./client.key -in ./client.cert -chain -CAfile ../rootCA.cert
    
    ## Import the pkcs#12 file into the auto-login wallet
    orapki wallet import_pkcs12 -wallet ../client -pkcs12file ./client.p12
    
    ## Review the content of the wallet
    orapki wallet display -wallet ../client/ -complete