apps: get user certificate

This commit is contained in:
Girish Ramakrishnan
2021-05-07 21:37:23 -07:00
parent 84af9580a6
commit 593a61f51b
+12
View File
@@ -44,6 +44,8 @@ exports = module.exports = {
getLocalLogfilePaths,
getLogs,
getCertificate,
start,
stop,
restart,
@@ -115,6 +117,7 @@ const appdb = require('./appdb.js'),
backups = require('./backups.js'),
BoxError = require('./boxerror.js'),
constants = require('./constants.js'),
database = require('./database.js'),
debug = require('debug')('box:apps'),
docker = require('./docker.js'),
domaindb = require('./domaindb.js'),
@@ -1414,6 +1417,15 @@ function getLogs(app, options, callback) {
return callback(null, transformStream);
}
async function getCertificate(subdomain, domain) {
assert.strictEqual(typeof subdomain, 'string');
assert.strictEqual(typeof domain, 'string');
const result = await database.query('SELECT certificateJson FROM subdomains WHERE subdomain=? AND domain=?', [ subdomain, domain ]);
if (result.length === 0) return null;
return JSON.parse(result[0].certificateJson);
}
// does a re-configure when called from most states. for install/clone errors, it re-installs with an optional manifest
// re-configure can take a dockerImage but not a manifest because re-configure does not clean up addons
function repair(app, data, auditSource, callback) {