mirror of
https://github.com/nodemailer/wildduck.git
synced 2024-12-27 10:21:11 +08:00
commit
c912b8d3f2
1 changed files with 31 additions and 3 deletions
|
@ -144,7 +144,7 @@ class CertHandler {
|
|||
}
|
||||
|
||||
const changes = {
|
||||
$set: updates
|
||||
$set: Object.assign({}, updates)
|
||||
};
|
||||
|
||||
let fp;
|
||||
|
@ -161,14 +161,17 @@ class CertHandler {
|
|||
let encodedPrivateKey = await encrypt(updates.privateKey, this.secret);
|
||||
|
||||
changes.$set = Object.assign({}, updates, { fp, privateKey: encodedPrivateKey });
|
||||
|
||||
changes.$inc = { v: 1 };
|
||||
}
|
||||
|
||||
if (updateOptions.certUpdated) {
|
||||
changes.$set['_acme.lastError'] = null;
|
||||
}
|
||||
|
||||
if (updates.privateKey || updateOptions.certUpdated) {
|
||||
changes.$inc = { v: 1 };
|
||||
changes.$set.updated = new Date();
|
||||
}
|
||||
|
||||
try {
|
||||
r = await this.database.collection('certs').findOneAndUpdate(query, changes, {
|
||||
upsert: false,
|
||||
|
@ -189,6 +192,15 @@ class CertHandler {
|
|||
throw err;
|
||||
}
|
||||
|
||||
if (updateOptions.certUpdated) {
|
||||
this.loggelf({
|
||||
short_message: `SNI cert updated for ${r.value.servername}`,
|
||||
_sni_servername: r.value.servername,
|
||||
_cert_action: 'update',
|
||||
_cert_expires: r.value.expires && r.value.expires.toISOString()
|
||||
});
|
||||
}
|
||||
|
||||
if (this.redis && updates.cert) {
|
||||
try {
|
||||
await publish(this.redis, {
|
||||
|
@ -368,6 +380,22 @@ class CertHandler {
|
|||
throw err;
|
||||
}
|
||||
|
||||
if (r.lastErrorObject.upserted) {
|
||||
this.loggelf({
|
||||
short_message: `SNI cert created for ${r.value.servername}`,
|
||||
_sni_servername: r.value.servername,
|
||||
_cert_action: 'create',
|
||||
_cert_expires: r.value.expires && r.value.expires.toISOString()
|
||||
});
|
||||
} else if (r.lastErrorObject.updatedExisting) {
|
||||
this.loggelf({
|
||||
short_message: `SNI cert updated for ${r.value.servername}`,
|
||||
_sni_servername: r.value.servername,
|
||||
_cert_action: 'update',
|
||||
_cert_expires: r.value.expires && r.value.expires.toISOString()
|
||||
});
|
||||
}
|
||||
|
||||
if (this.redis && certData.cert) {
|
||||
try {
|
||||
if (r.lastErrorObject.upserted) {
|
||||
|
|
Loading…
Reference in a new issue