store custom app certificates in subdomains table
the REST route and model code is still ununsed as before since there is no way to set the certs from the UI.
This commit is contained in:
35
src/apps.js
35
src/apps.js
@@ -728,8 +728,6 @@ function install(data, auditSource, callback) {
|
||||
portBindings = data.portBindings || null,
|
||||
accessRestriction = data.accessRestriction || null,
|
||||
icon = data.icon || null,
|
||||
cert = data.cert || null,
|
||||
key = data.key || null,
|
||||
memoryLimit = data.memoryLimit || 0,
|
||||
sso = 'sso' in data ? data.sso : null,
|
||||
debugMode = data.debugMode || null,
|
||||
@@ -794,11 +792,6 @@ function install(data, auditSource, callback) {
|
||||
validateLocations(locations, function (error, domainObjectMap) {
|
||||
if (error) return callback(error);
|
||||
|
||||
if (cert && key) {
|
||||
error = reverseProxy.validateCertificate(location, domainObjectMap[domain], { cert, key });
|
||||
if (error) return callback(new BoxError(BoxError.BAD_FIELD, error.message, { field: 'cert' }));
|
||||
}
|
||||
|
||||
debug('Will install app with id : ' + appId);
|
||||
|
||||
var data = {
|
||||
@@ -827,12 +820,6 @@ function install(data, auditSource, callback) {
|
||||
purchaseApp({ appId: appId, appstoreId: appStoreId, manifestId: manifest.id || 'customapp' }, function (error) {
|
||||
if (error) return callback(error);
|
||||
|
||||
// save cert to boxdata/certs
|
||||
if (cert && key) {
|
||||
let error = reverseProxy.setAppCertificateSync(location, domainObjectMap[domain], { cert, key });
|
||||
if (error) return callback(error);
|
||||
}
|
||||
|
||||
const task = {
|
||||
args: { restoreConfig: null, skipDnsSetup, overwriteDns },
|
||||
values: { },
|
||||
@@ -1164,28 +1151,30 @@ function setReverseProxyConfig(app, reverseProxyConfig, auditSource, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
function setCertificate(app, bundle, auditSource, callback) {
|
||||
function setCertificate(app, data, auditSource, callback) {
|
||||
assert.strictEqual(typeof app, 'object');
|
||||
assert(bundle && typeof bundle === 'object');
|
||||
assert(data && typeof data === 'object');
|
||||
assert.strictEqual(typeof auditSource, 'object');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
const appId = app.id;
|
||||
const { location, domain, cert, key } = data;
|
||||
|
||||
domains.get(app.domain, function (error, domainObject) {
|
||||
domains.get(domain, function (error, domainObject) {
|
||||
if (error) return callback(error);
|
||||
|
||||
if (bundle.cert && bundle.key) {
|
||||
error = reverseProxy.validateCertificate(app.location, domainObject, { cert: bundle.cert, key: bundle.key });
|
||||
if (error) return callback(new BoxError(BoxError.BAD_FIELD, error.message, { field: 'cert' }));
|
||||
if (cert && key) {
|
||||
error = reverseProxy.validateCertificate(location, domainObject, { cert, key });
|
||||
if (error) return callback(error);
|
||||
}
|
||||
|
||||
error = reverseProxy.setAppCertificateSync(app.location, domainObject, { cert: bundle.cert, key: bundle.key });
|
||||
if (error) return callback(error);
|
||||
reverseProxy.setAppCertificateSync(location, domainObject, { cert, key }, function (error) {
|
||||
if (error) return callback(error);
|
||||
|
||||
eventlog.add(eventlog.ACTION_APP_CONFIGURE, auditSource, { appId, app, cert: bundle.cert, key: bundle.key });
|
||||
eventlog.add(eventlog.ACTION_APP_CONFIGURE, auditSource, { appId, app, cert, key });
|
||||
|
||||
callback();
|
||||
callback();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user