1
0
Fork 0

various fixes

refactor/models
Matthew 2020-05-08 19:10:53 -04:00
parent 8c611ff5b9
commit 202f87e832
No known key found for this signature in database
GPG Key ID: 766BE43AE75F7559
1 changed files with 4 additions and 7 deletions

View File

@ -47,7 +47,7 @@ export default class CWG_Create extends Command {
try {
answer = await this.client.util.messageCollector(
message,
`***${this.client.stores.emojis.error} ***This port is already binded to a domain. Do you wish to continue? (y/n)***`,
`***${this.client.stores.emojis.error} This port is already binded to a domain. Do you wish to continue? (y/n)***`,
30000, true, ['y', 'n'], (msg) => msg.author.id === message.author.id && msg.channel.id === message.channel.id,
);
} catch (error) {
@ -189,16 +189,13 @@ export default class CWG_Create extends Command {
if (!this.isValidCertificateChain(certChain)) throw new Error('Invalid Certificate Chain');
if (!this.isValidPrivateKey(privateKey)) throw new Error('Invalid Private Key');
const path = `/opt/CloudServices/temp/${domain}`;
const temp = [writeFile(`${path}.chain.crt`, certChain), writeFile(`${path}.key.pem`, privateKey)];
const removeFiles = [unlink(`${path}.chain.crt`), unlink(`${path}.key.pem`)];
await Promise.all(temp);
await Promise.all([writeFile(`${path}.chain.crt`, certChain), writeFile(`${path}.key.pem`, privateKey)]);
if (!this.isMatchingPair(`${path}.chain.crt`, `${path}.key.pem`)) {
await Promise.all(removeFiles);
await Promise.all([unlink(`${path}.chain.crt`), unlink(`${path}.key.pem`)]);
throw new Error('Certificate and Private Key do not match');
}
const tasks = [writeFile(`/etc/nginx/ssl/${domain}.chain.crt`, certChain), writeFile(`/etc/nginx/ssl/${domain}.key.pem`, privateKey)];
await Promise.all(tasks);
await Promise.all([writeFile(`/etc/ssl/certs/cwg/${domain}.chain.crt`, certChain), writeFile(`/etc/certs/private/cwg/${domain}.key.pem`, privateKey)]);
return { cert: `/etc/nginx/ssl/${domain}.chain.crt`, key: `/etc/nginx/ssl/${domain}.key.pem` };
}