Permalink
Browse files

Resolve #48 Check www subdomain before SSL generation

  • Loading branch information...
bgornicki committed Nov 25, 2018
1 parent 18df6bd commit 128b0ac66adf39a6f817791f3c1bef2db7564504
Showing with 6 additions and 21 deletions.
  1. +1 −1 engrave/reload-blogs.sh
  2. +3 −19 engrave/src/modules/Domains.ts
  3. +2 −1 engrave/src/modules/SSL.ts
@@ -6,5 +6,5 @@ for i in $(find instances/ -maxdepth 1 ! -path instances/ -type d);
do
BLOG=$(echo $i | sed 's#instances/##'); # pm2 process is equal to directory name but without trailing dot and slash
echo $BLOG;
sudo pm2 reload $BLOG # restart blog instance
pm2 reload $BLOG # restart blog instance
done
@@ -74,10 +74,6 @@ export class Domains {
.post(this.apiAuthorizedAddress)
.accept('json')
.send(orderRequest)

const createdDomainResponse = JSON.parse(result.text);
console.log(createdDomainResponse);

} catch (error) {
console.log(error);
throw error;
@@ -162,10 +158,7 @@ export class Domains {
type: 'A',
answer: process.env.SERVER_IP,
ttl: 300
});

console.log(answer);

});
}

private static async createDomainRecordsForEngrave(domain: string) {
@@ -178,9 +171,7 @@ export class Domains {
answer: process.env.SERVER_IP,
ttl: 300
});

console.log(record);


record = await superagent
.post(this.apiAuthorizedAddress + `/${domain}/records`)
.accept('json')
@@ -191,8 +182,6 @@ export class Domains {
ttl: 300
});

console.log(record);

record = await superagent
.post(this.apiAuthorizedAddress + `/${domain}/records`)
.accept('json')
@@ -202,9 +191,7 @@ export class Domains {
answer: process.env.SERVER_IP,
ttl: 300
});

console.log(record);
}
}

static async getDomainPrice(domain: string): Promise<number> {
const result = await superagent
@@ -228,9 +215,6 @@ export class Domains {
await this.createDomainRecordsForEngrave(domain)
}

const configuredRecords = await this.getDomainRecords(domain);
console.log(configuredRecords);

} catch (error) {
console.log(error);
throw new Error("Error while configuring records for domain")
@@ -52,7 +52,8 @@ export class SSLModule {

for(const blog of blogs) {
try {
if (await SSLModule.checkIfDomainPointsEngraveServer(blog.domain)) {
if (await SSLModule.checkIfDomainPointsEngraveServer(blog.domain) &&
await SSLModule.checkIfDomainPointsEngraveServer('www.' + blog.domain)) {
console.log("Unsecured blog: ", blog.domain);
await SSLModule.generateCertificatesForDomain(blog.domain);
console.log(" * SSL generated for ", blog.domain);

0 comments on commit 128b0ac

Please sign in to comment.