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

db.rotateCertificates()(mongoshメソッド)

バージョン 5.0 の新機能。

db.rotateCertificates(message)

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

db.rotateCertificates(message)

The db.rotateCertificates() method takes the following optional argument:

Parameter
タイプ
説明

message

string

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

db.rotateCertificates()rotateCertificatesメソッドは コマンドをラップします。

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

重要

このコマンドは、MongoDB Atlas クラスターではサポートされていません。すべてのコマンドに対する Atlas のサポートについては、「サポートされていないコマンド」を参照してください。

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

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

注意

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

The db.rotateCertificates() method returns a document with the following field:

フィールド
タイプ
説明

ok

ブール

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

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

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

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

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

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

  2. 証明書ローテーションを実行する またはmongosh mongodmongosインスタンスに を接続します。

  3. Run db.rotateCertificates() to rotate the certificates used by the mongod or mongos instance.

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

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

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

If you have configured OCSP for your deployment, the db.rotateCertificates() method will also fetch stapled OCSP responses during rotation.

The db.rotateCertificates() method 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, db.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 db.rotateCertificates() method. The rotateCertificates action is part of the hostManager role.

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

db.rotateCertificates()

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

db.rotateCertificates("message": "Rotating certificates")