make sure that fingerprint is shown in acme respose

This commit is contained in:
Andris Reinman 2021-09-10 12:27:31 +03:00
parent 4ee6f98ed1
commit dfe694161b
2 changed files with 10 additions and 9 deletions

View file

@ -329,12 +329,12 @@ module.exports = (db, server) => {
);
server.get(
'/certs/:certs',
'/certs/:cert',
tools.asyncifyJson(async (req, res, next) => {
res.charSet('utf-8');
const schema = Joi.object().keys({
certs: Joi.string().hex().lowercase().length(24).required(),
cert: Joi.string().hex().lowercase().length(24).required(),
sess: sessSchema,
ip: sessIPSchema
});
@ -357,11 +357,11 @@ module.exports = (db, server) => {
// permissions check
req.validate(roles.can(req.role).readAny('certs'));
let certs = new ObjectId(result.value.certs);
let cert = new ObjectId(result.value.certs);
let response;
try {
response = await certHandler.get({ _id: certs }, false);
response = await certHandler.get({ _id: cert }, false);
} catch (err) {
switch (err.code) {
case 'InputValidationError':

View file

@ -377,14 +377,14 @@ class CertHandler {
ev: CERT_CREATED,
cert: r.value._id.toString(),
servername,
fingerprint: certData.fingerprint
fingerprint: certData.fingerprint || certData.fp
});
} else if (r.lastErrorObject.updatedExisting) {
await publish(this.redis, {
ev: CERT_UPDATED,
cert: r.value._id.toString(),
servername,
fingerprint: certData.fingerprint
fingerprint: certData.fingerprint || certData.fp
});
}
} catch (err) {
@ -396,7 +396,7 @@ class CertHandler {
id: r.value._id.toString(),
servername,
description: certData.description,
fingerprint: certData.fingerprint,
fingerprint: certData.fingerprint || certData.fp,
expires: certData.expires && certData.expires.toISOString(),
altNames: certData.altNames,
acme: certData.acme
@ -410,10 +410,11 @@ class CertHandler {
id: certData._id.toString(),
servername: certData.servername,
description: certData.description,
fingerprint: certData.fingerprint,
fingerprint: certData.fingerprint || certData.fp,
expires: certData.expires,
altNames: certData.altNames,
acme: !!certData.acme,
hasCert: (!!certData.privateKe && certData.cert) || false,
created: certData.created
};
@ -477,7 +478,7 @@ class CertHandler {
ev: CERT_DELETED,
cert: r.value._id,
servername: r.value.servername,
fingerprint: r.value.fingerprint
fingerprint: r.value.fingerprint || r.value.fp
});
} catch (err) {
// ignore?