@@ -209,6 +209,7 @@ const internalCertificate = {
209
209
. patchAndFetchById ( certificate . id , {
210
210
expires_on : moment ( cert_info . dates . to , 'X' ) . format ( 'YYYY-MM-DD HH:mm:ss' )
211
211
} )
212
+ . then ( utils . omitRow ( omissions ( ) ) )
212
213
. then ( ( saved_row ) => {
213
214
// Add cert data for audit log
214
215
saved_row . meta = _ . assign ( { } , saved_row . meta , {
@@ -732,29 +733,29 @@ const internalCertificate = {
732
733
733
734
return utils . exec ( 'openssl x509 -in ' + certificate_file + ' -subject -noout' )
734
735
. then ( ( result ) => {
736
+ // Examples:
737
+ // subject=CN = *.jc21.com
735
738
// subject=CN = something.example.com
736
739
const regex = / (?: s u b j e c t = ) ? [ ^ = ] + = \s + ( \S + ) / gim;
737
740
const match = regex . exec ( result ) ;
738
-
739
- if ( typeof match [ 1 ] === 'undefined' ) {
740
- throw new error . ValidationError ( 'Could not determine subject from certificate: ' + result ) ;
741
+ if ( match && typeof match [ 1 ] !== 'undefined' ) {
742
+ certData [ 'cn' ] = match [ 1 ] ;
741
743
}
742
-
743
- certData [ 'cn' ] = match [ 1 ] ;
744
744
} )
745
745
. then ( ( ) => {
746
746
return utils . exec ( 'openssl x509 -in ' + certificate_file + ' -issuer -noout' ) ;
747
747
} )
748
+
748
749
. then ( ( result ) => {
750
+ // Examples:
749
751
// issuer=C = US, O = Let's Encrypt, CN = Let's Encrypt Authority X3
752
+ // issuer=C = US, O = Let's Encrypt, CN = E5
753
+ // issuer=O = NginxProxyManager, CN = NginxProxyManager Intermediate CA","O = NginxProxyManager, CN = NginxProxyManager Intermediate CA
750
754
const regex = / ^ (?: i s s u e r = ) ? ( .* ) $ / gim;
751
755
const match = regex . exec ( result ) ;
752
-
753
- if ( typeof match [ 1 ] === 'undefined' ) {
754
- throw new error . ValidationError ( 'Could not determine issuer from certificate: ' + result ) ;
756
+ if ( match && typeof match [ 1 ] !== 'undefined' ) {
757
+ certData [ 'issuer' ] = match [ 1 ] ;
755
758
}
756
-
757
- certData [ 'issuer' ] = match [ 1 ] ;
758
759
} )
759
760
. then ( ( ) => {
760
761
return utils . exec ( 'openssl x509 -in ' + certificate_file + ' -dates -noout' ) ;
@@ -829,16 +830,16 @@ const internalCertificate = {
829
830
requestLetsEncryptSsl : ( certificate ) => {
830
831
logger . info ( 'Requesting Let\'sEncrypt certificates for Cert #' + certificate . id + ': ' + certificate . domain_names . join ( ', ' ) ) ;
831
832
832
- const cmd = certbotCommand + ' certonly ' +
833
- ' --config "' + letsencryptConfig + '" ' +
833
+ const cmd = ` ${ certbotCommand } certonly ` +
834
+ ` --config ' ${ letsencryptConfig } ' ` +
834
835
'--work-dir "/tmp/letsencrypt-lib" ' +
835
836
'--logs-dir "/tmp/letsencrypt-log" ' +
836
- ' --cert-name "npm-' + certificate . id + '" ' +
837
+ ` --cert-name "npm-${ certificate . id } " ` +
837
838
'--agree-tos ' +
838
839
'--authenticator webroot ' +
839
- ' --email "' + certificate . meta . letsencrypt_email + '" ' +
840
+ ` --email ' ${ certificate . meta . letsencrypt_email } ' ` +
840
841
'--preferred-challenges "dns,http" ' +
841
- ' --domains "' + certificate . domain_names . join ( ',' ) + '" ' +
842
+ ` --domains "${ certificate . domain_names . join ( ',' ) } " ` +
842
843
( letsencryptServer !== null ? `--server '${ letsencryptServer } ' ` : '' ) +
843
844
( letsencryptStaging && letsencryptServer === null ? '--staging ' : '' ) ;
844
845
@@ -871,25 +872,26 @@ const internalCertificate = {
871
872
const hasConfigArg = certificate . meta . dns_provider !== 'route53' ;
872
873
873
874
let mainCmd = certbotCommand + ' certonly ' +
874
- ' --config "' + letsencryptConfig + '" ' +
875
+ ` --config ' ${ letsencryptConfig } ' ` +
875
876
'--work-dir "/tmp/letsencrypt-lib" ' +
876
877
'--logs-dir "/tmp/letsencrypt-log" ' +
877
- ' --cert-name " npm-' + certificate . id + '" ' +
878
+ ` --cert-name ' npm-${ certificate . id } ' ` +
878
879
'--agree-tos ' +
879
- ' --email "' + certificate . meta . letsencrypt_email + '" ' +
880
- ' --domains "' + certificate . domain_names . join ( ',' ) + '" ' +
881
- ' --authenticator ' + dnsPlugin . full_plugin_name + ' ' +
880
+ ` --email ' ${ certificate . meta . letsencrypt_email } ' ` +
881
+ ` --domains ' ${ certificate . domain_names . join ( ',' ) } ' ` +
882
+ ` --authenticator '${ dnsPlugin . full_plugin_name } ' ` +
882
883
(
883
884
hasConfigArg
884
- ? '--' + dnsPlugin . full_plugin_name + ' -credentials "' + credentialsLocation + '"'
885
+ ? `-- ${ dnsPlugin . full_plugin_name } -credentials ' ${ credentialsLocation } ' `
885
886
: ''
886
887
) +
887
888
(
888
889
certificate . meta . propagation_seconds !== undefined
889
- ? ' --' + dnsPlugin . full_plugin_name + ' -propagation-seconds ' + certificate . meta . propagation_seconds
890
+ ? `-- ${ dnsPlugin . full_plugin_name } -propagation-seconds '${ certificate . meta . propagation_seconds } ' `
890
891
: ''
891
892
) +
892
- ( letsencryptStaging ? ' --staging' : '' ) ;
893
+ ( letsencryptServer !== null ? `--server '${ letsencryptServer } ' ` : '' ) +
894
+ ( letsencryptStaging && letsencryptServer === null ? '--staging ' : '' ) ;
893
895
894
896
// Prepend the path to the credentials file as an environment variable
895
897
if ( certificate . meta . dns_provider === 'route53' ) {
@@ -966,14 +968,15 @@ const internalCertificate = {
966
968
logger . info ( 'Renewing Let\'sEncrypt certificates for Cert #' + certificate . id + ': ' + certificate . domain_names . join ( ', ' ) ) ;
967
969
968
970
const cmd = certbotCommand + ' renew --force-renewal ' +
969
- ' --config "' + letsencryptConfig + '" ' +
971
+ ` --config ' ${ letsencryptConfig } ' ` +
970
972
'--work-dir "/tmp/letsencrypt-lib" ' +
971
973
'--logs-dir "/tmp/letsencrypt-log" ' +
972
- ' --cert-name " npm-' + certificate . id + '" ' +
974
+ ` --cert-name ' npm-${ certificate . id } ' ` +
973
975
'--preferred-challenges "dns,http" ' +
974
976
'--no-random-sleep-on-renew ' +
975
977
'--disable-hook-validation ' +
976
- ( letsencryptStaging ? '--staging' : '' ) ;
978
+ ( letsencryptServer !== null ? `--server '${ letsencryptServer } ' ` : '' ) +
979
+ ( letsencryptStaging && letsencryptServer === null ? '--staging ' : '' ) ;
977
980
978
981
logger . info ( 'Command:' , cmd ) ;
979
982
@@ -998,13 +1001,14 @@ const internalCertificate = {
998
1001
logger . info ( `Renewing Let'sEncrypt certificates via ${ dnsPlugin . name } for Cert #${ certificate . id } : ${ certificate . domain_names . join ( ', ' ) } ` ) ;
999
1002
1000
1003
let mainCmd = certbotCommand + ' renew --force-renewal ' +
1001
- ' --config "' + letsencryptConfig + '" ' +
1004
+ ` --config "${ letsencryptConfig } " ` +
1002
1005
'--work-dir "/tmp/letsencrypt-lib" ' +
1003
1006
'--logs-dir "/tmp/letsencrypt-log" ' +
1004
- ' --cert-name " npm-' + certificate . id + '" ' +
1007
+ ` --cert-name ' npm-${ certificate . id } ' ` +
1005
1008
'--disable-hook-validation ' +
1006
1009
'--no-random-sleep-on-renew ' +
1007
- ( letsencryptStaging ? ' --staging' : '' ) ;
1010
+ ( letsencryptServer !== null ? `--server '${ letsencryptServer } ' ` : '' ) +
1011
+ ( letsencryptStaging && letsencryptServer === null ? '--staging ' : '' ) ;
1008
1012
1009
1013
// Prepend the path to the credentials file as an environment variable
1010
1014
if ( certificate . meta . dns_provider === 'route53' ) {
@@ -1030,12 +1034,13 @@ const internalCertificate = {
1030
1034
logger . info ( 'Revoking Let\'sEncrypt certificates for Cert #' + certificate . id + ': ' + certificate . domain_names . join ( ', ' ) ) ;
1031
1035
1032
1036
const mainCmd = certbotCommand + ' revoke ' +
1033
- ' --config "' + letsencryptConfig + '" ' +
1037
+ ` --config ' ${ letsencryptConfig } ' ` +
1034
1038
'--work-dir "/tmp/letsencrypt-lib" ' +
1035
1039
'--logs-dir "/tmp/letsencrypt-log" ' +
1036
- ' --cert-path " /etc/letsencrypt/live/npm-' + certificate . id + ' /fullchain.pem" ' +
1040
+ ` --cert-path ' /etc/letsencrypt/live/npm-${ certificate . id } /fullchain.pem' ` +
1037
1041
'--delete-after-revoke ' +
1038
- ( letsencryptStaging ? '--staging' : '' ) ;
1042
+ ( letsencryptServer !== null ? `--server '${ letsencryptServer } ' ` : '' ) +
1043
+ ( letsencryptStaging && letsencryptServer === null ? '--staging ' : '' ) ;
1039
1044
1040
1045
// Don't fail command if file does not exist
1041
1046
const delete_credentialsCmd = `rm -f '/etc/letsencrypt/credentials/credentials-${ certificate . id } ' || true` ;
0 commit comments