Skip to content

Commit f145006

Browse files
committed
Added more debug logs
1 parent a4c0148 commit f145006

File tree

1 file changed

+21
-25
lines changed

1 file changed

+21
-25
lines changed

backend/internal/certificate.js

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ const internalCertificate = {
449449
*/
450450
writeCustomCert: (certificate) => {
451451
if (debug_mode) {
452-
logger.info('Writing Custom Certificate:', certificate);
452+
logger.debug('Writing Custom Certificate:', certificate);
453453
}
454454

455455
let dir = '/data/custom_ssl/npm-' + certificate.id;
@@ -575,18 +575,14 @@ const internalCertificate = {
575575
throw new error.ValidationError('Cannot upload certificates for this type of provider');
576576
}
577577

578-
if (debug_mode) {
579-
logger.info('certificate.upload data: ' + JSON.stringify(data));
580-
}
581-
582578
return internalCertificate.validate(data)
583579
.then((validations) => {
584580
if (typeof validations.certificate === 'undefined') {
585581
throw new error.ValidationError('Certificate file was not provided');
586582
}
587583

588584
if (debug_mode) {
589-
logger.info('certificate.upload validate result: ' + JSON.stringify(validations));
585+
logger.debug('certificate.upload validate result: ' + JSON.stringify(validations));
590586
}
591587

592588
_.map(data.files, (file, name) => {
@@ -603,15 +599,15 @@ const internalCertificate = {
603599
})
604600
.then((certificate) => {
605601
if (debug_mode) {
606-
logger.info('certificate.upload row.meta: ' + row.meta);
602+
logger.debug('certificate.upload row.meta: ' + row.meta);
607603
}
608604
certificate.meta = row.meta;
609605
return internalCertificate.writeCustomCert(certificate);
610606
});
611607
})
612608
.then(() => {
613609
if (debug_mode) {
614-
logger.info('certificate.upload completed');
610+
logger.debug('certificate.upload completed');
615611
}
616612
return _.pick(row.meta, internalCertificate.allowed_ssl_files);
617613
});
@@ -631,21 +627,21 @@ const internalCertificate = {
631627
const cmd = 'openssl ' + key_type + ' -in ' + filepath + ' -check -noout 2>&1 ';
632628

633629
if (debug_mode) {
634-
logger.info('checkPrivateKey type: ' + key_type + ' ...');
635-
logger.info('checkPrivateKey command: ' + cmd);
630+
logger.debug('checkPrivateKey type: ' + key_type + ' ...');
631+
logger.debug('checkPrivateKey command: ' + cmd);
636632
}
637633

638634
return utils.exec(cmd)
639635
.then((result) => {
640636
if (debug_mode) {
641-
logger.info('checkPrivateKey result: ' + result);
637+
logger.debug('checkPrivateKey result: ' + result);
642638
}
643639
if (!result.toLowerCase().includes('key ok') && !result.toLowerCase().includes('key valid') ) {
644640
throw new error.ValidationError('Result Validation Error: ' + result);
645641
}
646642
fs.unlinkSync(filepath);
647643
if (debug_mode) {
648-
logger.info('checkPrivateKey completed');
644+
logger.debug('checkPrivateKey completed');
649645
}
650646
return true;
651647
}).catch((err) => {
@@ -688,13 +684,13 @@ const internalCertificate = {
688684
const cmd = 'openssl x509 -in ' + certificate_file + ' -subject -noout';
689685

690686
if (debug_mode) {
691-
logger.info('getCertificateInfoFromFile command: ' + cmd);
687+
logger.debug('getCertificateInfoFromFile command: ' + cmd);
692688
}
693689

694690
return utils.exec(cmd)
695691
.then((result) => {
696692
if (debug_mode) {
697-
logger.info('getCertificateInfoFromFile result: ' + result);
693+
logger.debug('getCertificateInfoFromFile result: ' + result);
698694
}
699695
// subject=CN = something.example.com
700696
let regex = /(?:subject=)?[^=]+=\s+(\S+)/gim;
@@ -709,13 +705,13 @@ const internalCertificate = {
709705
.then(() => {
710706
const cmd2 = 'openssl x509 -in ' + certificate_file + ' -issuer -noout';
711707
if (debug_mode) {
712-
logger.info('getCertificateInfoFromFile command: ' + cmd2);
708+
logger.debug('getCertificateInfoFromFile command: ' + cmd2);
713709
}
714710
return utils.exec(cmd2);
715711
})
716712
.then((result) => {
717713
if (debug_mode) {
718-
logger.info('getCertificateInfoFromFile result: ' + result);
714+
logger.debug('getCertificateInfoFromFile result: ' + result);
719715
}
720716
// issuer=C = US, O = Let's Encrypt, CN = Let's Encrypt Authority X3
721717
let regex = /^(?:issuer=)?(.*)$/gim;
@@ -730,13 +726,13 @@ const internalCertificate = {
730726
.then(() => {
731727
const cmd3 = 'openssl x509 -in ' + certificate_file + ' -dates -noout';
732728
if (debug_mode) {
733-
logger.info('getCertificateInfoFromFile command: ' + cmd3);
729+
logger.debug('getCertificateInfoFromFile command: ' + cmd3);
734730
}
735731
return utils.exec(cmd3);
736732
})
737733
.then((result) => {
738734
if (debug_mode) {
739-
logger.info('getCertificateInfoFromFile result: ' + result);
735+
logger.debug('getCertificateInfoFromFile result: ' + result);
740736
}
741737
// notBefore=Jul 14 04:04:29 2018 GMT
742738
// notAfter=Oct 12 04:04:29 2018 GMT
@@ -773,7 +769,7 @@ const internalCertificate = {
773769
};
774770

775771
if (debug_mode) {
776-
logger.info('getCertificateInfoFromFile completed: ' + JSON.stringify(cert_data));
772+
logger.debug('getCertificateInfoFromFile completed: ' + JSON.stringify(cert_data));
777773
}
778774

779775
return cert_data;
@@ -820,7 +816,7 @@ const internalCertificate = {
820816
(le_staging ? '--staging' : '');
821817

822818
if (debug_mode) {
823-
logger.info('Command:', cmd);
819+
logger.debug('requestLetsEncryptSsl command:', cmd);
824820
}
825821

826822
return utils.exec(cmd)
@@ -878,7 +874,7 @@ const internalCertificate = {
878874
}
879875

880876
if (debug_mode) {
881-
logger.info('Command:', `${credentials_cmd} && ${prepare_cmd} && ${main_cmd}`);
877+
logger.debug('requestLetsEncryptSslWithDnsChallenge command:', `${credentials_cmd} && ${prepare_cmd} && ${main_cmd}`);
882878
}
883879

884880
return utils.exec(credentials_cmd)
@@ -959,7 +955,7 @@ const internalCertificate = {
959955
(le_staging ? '--staging' : '');
960956

961957
if (debug_mode) {
962-
logger.info('Command:', cmd);
958+
logger.debug_mode('renewLetsEncryptSsl command:', cmd);
963959
}
964960

965961
return utils.exec(cmd)
@@ -995,7 +991,7 @@ const internalCertificate = {
995991
}
996992

997993
if (debug_mode) {
998-
logger.info('Command:', main_cmd);
994+
logger.debug('renewLetsEncryptSslWithDnsChallenge command:', main_cmd);
999995
}
1000996

1001997
return utils.exec(main_cmd)
@@ -1022,7 +1018,7 @@ const internalCertificate = {
10221018
const delete_credentials_cmd = `rm -f '/etc/letsencrypt/credentials/credentials-${certificate.id}' || true`;
10231019

10241020
if (debug_mode) {
1025-
logger.info('Command:', main_cmd + '; ' + delete_credentials_cmd);
1021+
logger.debug('revokeLetsEncryptSsl command:', main_cmd + '; ' + delete_credentials_cmd);
10261022
}
10271023

10281024
return utils.exec(main_cmd)
@@ -1033,7 +1029,7 @@ const internalCertificate = {
10331029
})
10341030
.catch((err) => {
10351031
if (debug_mode) {
1036-
logger.error(err.message);
1032+
logger.debug('revokeLetsEncryptSsl error:', err.message);
10371033
}
10381034

10391035
if (throw_errors) {

0 commit comments

Comments
 (0)