AI エージェント向け: ドキュメントインデックスは https://www.mongodb.com/ja-jp/docs/llms.txt で利用できます。すべてのページの markdown バージョンは、いずれかの URL パスに .md を追加することで利用できます。
Docs Menu

rotateCertificates(データベースコマンド)

バージョン 5.0 の新機能。

rotateCertificates

Rotates the currently used TLS certificates for a mongod or mongos to use the updated values for these certificates defined in the configuration file.

このコマンドは、次の環境でホストされている配置で使用できます。

  • MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud

注意

This command is supported in all MongoDB Atlas clusters. For information on Atlas support for all commands, see Unsupported Commands.

  • MongoDB Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン

  • MongoDB Community: ソースが利用可能で、無料で使用できる自己管理型の MongoDB のバージョン

注意

Atlas は証明書を自動的にローテーションします。Atlas を使用する場合、rotateCertificates コマンドを実行する必要はありません。証明書を手動でローテーションする場合にのみ、rotateCertificates コマンドを使用します。

このコマンドの構文は、次のとおりです。

db.runCommand(
{
rotateCertificates: 1,
message: "<optional log message>"
}
)

コマンドは、次の任意フィールドがあります。

Parameter
タイプ
説明

message

string

任意サーバーがログファイルと監査ファイルに記録するメッセージ。

The rotateCertificates command returns a document with the following field:

フィールド
タイプ
説明

ok

ブール

コマンドの実行状態が入ります。 成功した場合はtrue 、エラーが発生した場合はfalseになります。 falseの場合、 errmsgフィールドには詳細なエラーメッセージが追加されます。

ローテーションには次の証明書が含まれます。

1 つまたは複数の証明書をローテーションする。

  1. 次の制約に注意しながら、ファイルシステム上でローテーションしたい証明書を置き換えます。

    • 新しい証明書はそれぞれ、置き換える証明書と同じファイル名と同じファイルパスを持っている必要があります。

    • 暗号化された TLS Certificate をローテーションする場合、そのパスワードは古い証明書のパスワードと同じである必要があります(certificateKeyFilePassword 構成ファイル設定で指定)。証明書のローテーションでは、対話型のパスワード プロンプトはサポートされません。

  2. Connect mongosh to the mongod or mongos instance that you wish to perform certificate rotation on.

  3. Run the rotateCertificates command to rotate the certificates used by the mongod or mongos instance.

証明書のローテーションが行われると、次のようになります。

  • mongod または mongos インスタンスへの既存の接続は終了されず、古い証明書が引き続き使用されます。

  • 新しい接続では新しい証明書が使用されます。

If you have configured OCSP for your deployment, the rotateCertificates command will also fetch stapled OCSP responses during rotation.

The rotateCertificates command may be run on a running mongod or mongos regardless of replication status.

Only one instance of db.rotateCertificates() or rotateCertificates may run on each mongod or mongos process at a time. Attempting to initiate a second instance while one is already running will result in an error.

証明書ファイルが正しくない、期限切れ、取り消されている、または見つからない場合、証明書のローテーションは失敗しますが、既存の TLS 構成が無効になったり、実行中の mongod または mongos プロセスが終了したりすることはありません。

If the mongod or mongos is running with --tlsCertificateSelector set to thumbprint, rotateCertificates will fail and write a warning message to the log file.

ローテーションに成功すると、サブジェクト名、サムプリント、およびサーバー証明書のサムプリントの有効期間が、構成されたログ出力先にログとして記録されます。 監査が有効になっている場合は、この情報も 監査ログ に書き込まれます。

Linux と Windows プラットフォームでは、 CRL fileが存在する場合、そのサムプリントと有効期間もこれらのロケーションにログ化されます。

You must have the rotateCertificates action in order to use the rotateCertificates command. The rotateCertificates action is part of the hostManager role.

次の操作では、更新された証明書情報を指定するために構成ファイルを適切に更新した後、実行中のmongodインスタンス上の証明書をローテーションします。

db.adminCommand( { rotateCertificates: 1 } )

以下の は上記と同じ操作を実行しますが、ローテーション時にカスタム ログ メッセージをログファイルと監査ファイルに書込みます。

db.adminCommand( { rotateCertificates: 1, message: "Rotating certificates" } )