Skip to content

Commit

Permalink
Use that new API
Browse files Browse the repository at this point in the history
  • Loading branch information
willnode committed Nov 11, 2024
1 parent 7613a77 commit ac78512
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
27 changes: 12 additions & 15 deletions src/executor/runnersub.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ export async function runConfigSubdomain(config, domaindata, subdomain, sshExec,
var sharedSSL = regenerateSsl ? null : detectCanShareSSL(subdomain);
nginxNodes = await nginxExec.get(subdomain);
nginxInfos = nginxExec.extractInfo(nginxNodes, subdomain);
var expectCert = sharedSSL ? path.join(sharedSSL, 'ssl.combined') : (subdomaindata['SSL cert and CA file'] || subdomaindata['SSL cert file']);
var expectKey = sharedSSL ? path.join(sharedSSL, 'ssl.key') : subdomaindata['SSL key file'];
var expectCert = sharedSSL ? path.join(sharedSSL.path, 'ssl.combined') : (subdomaindata['SSL cert and CA file'] || subdomaindata['SSL cert file']);
var expectKey = sharedSSL ? path.join(sharedSSL.path, 'ssl.key') : subdomaindata['SSL key file'];
if ((!expectCert || !expectKey) && !regenerateSsl) {
expectedSslMode = 'off';
}
Expand All @@ -257,8 +257,8 @@ export async function runConfigSubdomain(config, domaindata, subdomain, sshExec,
subdomaindata = await virtualminExec.getDomainInfo(subdomain);
nginxNodes = await nginxExec.get(subdomain);
nginxInfos = nginxExec.extractInfo(nginxNodes, subdomain);
expectCert = sharedSSL ? path.join(sharedSSL, 'ssl.combined') : (subdomaindata['SSL cert and CA file'] || subdomaindata['SSL cert file']);
expectKey = sharedSSL ? path.join(sharedSSL, 'ssl.key') : subdomaindata['SSL key file'];
expectCert = sharedSSL ? path.join(sharedSSL.path, 'ssl.combined') : (subdomaindata['SSL cert and CA file'] || subdomaindata['SSL cert file']);
expectKey = sharedSSL ? path.join(sharedSSL.path, 'ssl.key') : subdomaindata['SSL key file'];
}
}
if (expectCert != nginxInfos.ssl_certificate) {
Expand Down Expand Up @@ -315,17 +315,14 @@ export async function runConfigSubdomain(config, domaindata, subdomain, sshExec,
} finally {
await writeLog("$> Applying nginx ssl config on " + subdomain);
await writeLog(await nginxExec.setDirect(subdomain, nginxInfos));
if (sharedSSL && sharedSSL.match(/\/(\d{10,})\//)) {
await writeLog("$> Applying SSL links with global domain");
let id = sharedSSL.match(/\/(\d{10,})\//)[1];
await writeLog(await virtualminExec.pushVirtualServerConfig(subdomaindata['ID'], {
'ssl_same': id,
'ssl_key': path.join(sharedSSL, 'ssl.key'),
'ssl_cert': path.join(sharedSSL, 'ssl.cert'),
'ssl_chain': path.join(sharedSSL, 'ssl.ca'),
'ssl_combined': path.join(sharedSSL, 'ssl.combined'),
}));
}
await writeLog("$> Applying SSL links with global domain");
await writeLog(await virtualminExec.pushVirtualServerConfig(subdomaindata['ID'], {
'ssl_same': sharedSSL.id,
'ssl_key': path.join(sharedSSL.path, 'ssl.key'),
'ssl_cert': path.join(sharedSSL.path, 'ssl.cert'),
'ssl_chain': path.join(sharedSSL.path, 'ssl.ca'),
'ssl_combined': path.join(sharedSSL.path, 'ssl.combined'),
}));
}
break;
case 'root':
Expand Down
4 changes: 4 additions & 0 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,10 @@ export function writeTo(path, content) {
});
}

/**
*
* @param {string} subdomain
*/
export function detectCanShareSSL(subdomain) {
const subdomainParts = subdomain.split('.');
for (const domain of Object.keys(sslWildcardsMap)) {
Expand Down

0 comments on commit ac78512

Please sign in to comment.