On this page本页内容
New in version 5.0.在版本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.mongod
或mongos
当前使用的TLS证书,以使用配置文件中定义的这些证书的更新值。
db.rotateCertificates(message)
The db.rotateCertificates()
method takes the following optional argument:db.rotateCertificates()
方法接受以下可选参数:
message | string |
The db.rotateCertificates()
method wraps the rotateCertificates
command.db.rotateCertificates()
方法包装rotateCertificates
命令。
The db.rotateCertificates()
method returns a document with the following field:db.rotateCertificates()
方法返回具有以下字段的文档:
ok | bool | true on success, or false if an error occurred. true ,发生错误时为false 。false , an errmsg field is additionally provided with a detailed error message. false ,errmsg 字段还将提供详细的错误消息。 |
Rotation includes the following certificates:轮换包括以下证书:
TLS Certificates
CRL (Certificate Revocation List) files
CA (Certificate Authority) files
To rotate one or more of these certificates:要轮换一个或多个证书:
Replace the certificate or certificates you wish to rotate on the filesystem, noting the following constraints:替换要在文件系统上轮换的一个或多个证书,注意以下约束:
TLS Certificate
, its password must be the same as the password for the old certificate (as specified to the certificateKeyFilePassword
configuration file setting). certificateKeyFilePassword
配置文件设置中指定的)。mongosh
to the mongod
or mongos
instance that you wish to perform certificate rotation on.mongosh
连接到您希望对其执行证书轮换的mongod
或mongos
实例。db.rotateCertificates()
to rotate the certificates used by the the mongod
or mongos
instance.db.rotateCertificates()
来轮换mongod
或mongos
实例使用的证书。When certificate rotation takes place:证书轮换发生时:
mongod
or mongos
instance are not terminated, and will continue to use the old certificates.mongod
或mongos
实例的现有连接不会终止,将继续使用旧证书。If you have configured 如果您已经为部署配置了OCSP
for your deployment, the db.rotateCertificates()
method will also fetch stapled OCSP responses during rotation.OCSP
,那么db.rotateCertificates()
>方法还将在轮换期间获取装订的OCSP响应。
The 无论复制状态如何,db.rotateCertificates()
method may be run on a running mongod
or mongos
regardless of replication status.db.rotateCertificates()
方法都可以在正在运行的mongod
或mongos
上运行。
Only one instance of 每次只能在每个db.rotateCertificates()
or rotateCertificates
may run on each mongod
or mongos
process at a time. mongod
或mongos
进程上运行db.rotateCertificates()
或rotateCertificates
的一个实例。Attempting to initiate a second instance while one is already running will result in an error.尝试在第二个实例已经运行时启动该实例将导致错误。
Incorrect, expired, revoked, or missing certificate files will cause the certificate rotation to fail, but will not invalidate the existing TLS configuration or terminate the running 不正确、过期、吊销或丢失的证书文件将导致证书轮换失败,但不会使现有TLS配置无效或终止正在运行的mongod
or mongos
process.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.mongod
或mongos
在--tlsCertificateSelector
设置为thumbprint
的情况下运行,dbrotateCertificates()
将失败,并将警告消息写入日志文件。
On successful rotation, the subject names, thumbprints, and the validity period of the server and cluster certificate thumbprints are logged to the configured log destination. 成功轮换后,服务器和群集证书指纹的使用者名称、指纹以及有效期将记录到配置的日志目标中。If auditing is enabled, this information is also written to the audit log.如果启用了审核,则此信息也会写入审核日志。
On Linux and Windows platforms, if a 在Linux和Windows平台上,如果存在CRL file
is present, its thumbprint and validity period are also logged to these locations.CRL file
,其指纹和有效期也会记录到这些位置。
You must have the 必须具有rotateCertificates
action in order to use the db.rotateCertificates()
method. rotateCertificates
操作才能使用db.rotateCertificates()
方法。The rotateCertificates
action is part of the hostManager
role.rotateCertificates
操作是hostManager
角色的一部分。
The following operation rotates the certificates on a running 在对配置文件进行适当更新以指定更新的证书信息之后,以下操作将在运行的mongod
instance, after having made the appropriate updates to the configuration file to specify the updated certificate information:mongod
实例上轮换证书:
db.rotateCertificates()
The following performs the same as above, but also writes a custom log message at rotation time to the log file and audit file:以下操作与上述操作相同,但也会在轮换时将自定义日志消息写入日志文件和审核文件:
db.rotateCertificates("message": "Rotating certificates")