6.3. キー管理の変更点


Eclipse Vert.x 4 では、キーの処理に主要な更新があります。最も重要な変更は、キーの読み込み時にパブリックバッファーとプライベートバッファーの区別がないことです。

以下のクラスが更新されました。

  • jce キーストアの使用に使用される io.vertx.ext.auth.KeyStoreOptions
  • 対称シークレットの処理に使用される io.vertx.ext.auth.SecretOptions
  • 公開鍵の処理に使用される io.vertx.ext.auth.PubSecKeyOptions

以下のセクションでは、キー管理の変更点を説明します。

6.3.1. シークレットオプションクラスが利用できない

SecretOptions クラスは利用できなくなりました。新しい PubSecKeyOptions クラスを使用して、暗号鍵と連携します。

以下の例は、Eclipse Vert.x 3.x リリースで SecretOptions クラスのメソッドが使用される方法を表しています。

new SecretOptions()
    .setType("HS256")
    .setSecret("password")

以下の例は、Eclipse Vert.x 4 で PubSecKeyOptions クラスのメソッドを使用する方法を示しています。

new PubSecKeyOptions()
    .setAlgorithm("HS256")
    .setSecretKey("password")

6.3.2. 公開鍵管理での更新

Eclipse Vert.x 3.x での公開秘密鍵管理の設定オブジェクトは以下を前提とします。

  • 鍵はキーペアとして設定します。
  • キーデータは、標準の区切り文字なしで PKCS8 でエンコードされた文字列です。

以下の例は、Eclipse Vert.x 3.x でキーペアを設定する方法を示しています。

new PubSecKeyOptions()
  .setPublicKey(
    // remove the PEM boundaries
    pubPemString
      .replaceAll("-----BEGIN PUBLIC KEY----")
      .replaceAll("-----END PUBLIC KEY----"))
  .setSecretKey(
    // remove the PEM boundaries
    secPemString
      .replaceAll("-----BEGIN PUBLIC KEY----")
      .replaceAll("-----END PUBLIC KEY----"));

Eclipse Vert.x 4 では、公開鍵と秘密鍵の両方を指定する必要があります。

以下の例は、Eclipse Vert.x 4 でキーペアを設定する方法を示しています。

PubSecKeyOptions pubKey =
  new PubSecKeyOptions()
    // the buffer is the exact contents of the PEM file and had boundaries included in it
    .setBuffer(pubPemString);

PubSecKeyOptions secKey =
  new PubSecKeyOptions()
    // the buffer is the exact contents of the PEM file and had boundaries included in it
    .setBuffer(secPemString);

PubSecKeyOptions を使用して X509 証明書に対応できるようになりました。

PubSecKeyOptions x509Certificate =
  new PubSecKeyOptions()
    // the buffer is the exact contents of the PEM file and had boundaries included in it
    .setBuffer(x509PemString);

6.3.3. キーストア管理の変更点

Eclipse Vert.x 3.x では、KeyStoreOptions はキーストアの形式が jceks であると仮定し、保存されたパスワードはキーのパスワードと同じであることを前提としています。jceks はプロプライエタリー形式であるため、代わりに JDK などの標準形式を使用することが推奨されます。

Eclipse Vert.x 4 で KeyStoreOptions を使用する場合は、ストアタイプを指定できます。たとえば、PKCS11 や PKCS12 などのストアタイプを設定できます。デフォルトのストアタイプは jceks です。

Eclipse Vert.x 3.x では、すべてのキーストアエントリーが同じパスワード (キーストアパスワード) を共有します。Eclipse Vert.x 4 では、各キーストアエントリーに専用のパスワードを指定できます。各キーストアエントリーにパスワードを設定しない場合は、キーストアパスワードをすべてのエントリーのデフォルトパスワードとして設定できます。

以下の例は、Eclipse Vert.x 3.x で jceks キーストアを読み込む方法を示しています。

new KeyStoreOptions()
  .setPath("path/to/keystore.jks")
  .setPassword("keystore-password");

Eclipse Vert.x 4 では、デフォルトの形式は JDK によって設定されるデフォルトの形式であることを前提としています。形式は、Java 9 以降の PKCS12 です。

以下の例は、Eclipse Vert.x 4 で jceks キーストアを読み込む方法を示しています。

new KeyStoreOptions()
  .setPath("path/to/keystore.jks")
  // Modern JDKs use `jceks` keystore. But this type is not the default
  // If the type is not set to `jceks` then probably `pkcs12` will be used
  .setType("jceks")
  .setPassword("keystore-password")
  // optionally if your keys have different passwords
  // and if a key specific id is not provided it defaults to
  // the keystore password
  .putPasswordProtection("key-id", "key-specific-password");
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

Red Hat ドキュメントについて

Legal Notice

Theme

© 2026 Red Hat
トップに戻る