定義
バージョン 5.0 の新機能。
db.rotateCertificates(message)Rotates the currently used TLS certificates for a
mongodormongosto 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タイプ説明messagestring
任意サーバーがログファイルと監査ファイルに記録するメッセージ。
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:
フィールド | タイプ | 説明 |
|---|---|---|
| ブール | コマンドの実行状態が入ります。 成功した場合は |
動作
ローテーションには次の証明書が含まれます。
CRL (Certificate Revocation List) files(Linux および Windows プラットフォーム上)
1 つまたは複数の証明書をローテーションする。
次の制約に注意しながら、ファイルシステム上でローテーションしたい証明書を置き換えます。
新しい証明書はそれぞれ、置き換える証明書と同じファイル名と同じファイルパスを持っている必要があります。
暗号化された
TLS Certificateをローテーションする場合、そのパスワードは古い証明書のパスワードと同じである必要があります(certificateKeyFilePassword構成ファイル設定で指定)。証明書のローテーションでは、対話型のパスワード プロンプトはサポートされません。
Run
db.rotateCertificates()to rotate the certificates used by themongodormongosinstance.
証明書のローテーションが行われると、次のようになります。
新しい接続では新しい証明書が使用されます。
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")