Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Je 65967 #254

Open
wants to merge 39 commits into
base: stage
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
04e25a4
Update manifest.jps
lazarenkoalexey Feb 23, 2022
a1befe0
Merge branch 'jelastic-jps:master' into multi
lazarenkoalexey Feb 28, 2022
484cdf6
Update manifest.jps
lazarenkoalexey Feb 28, 2022
159c2aa
small fixes
lazarenkoalexey Feb 28, 2022
47c3462
changed baseUrl
lazarenkoalexey Feb 28, 2022
77219d0
WP-8 [WP Standalone Multiregional] LE for multiregion deployment
lazarenkoalexey Mar 6, 2022
8eb9275
WP-8 [WP Standalone Multiregional] LE for multiregion deployment
lazarenkoalexey Mar 7, 2022
eedde49
WP-8 [WP Standalone Multiregional] LE for multiregion deployment
lazarenkoalexey Mar 8, 2022
8f356eb
WP-8 [WP Standalone Multiregional] LE for multiregion deployment
lazarenkoalexey Mar 8, 2022
30f2f66
WP-8 [WP Standalone Multiregional] LE for multiregion deployment
lazarenkoalexey Mar 8, 2022
0e4a13c
WP-8 [WP Standalone Multiregional] LE for multiregion deployment
lazarenkoalexey Mar 8, 2022
d2efc4d
WP-8 [WP Standalone Multiregional] LE for multiregion deployment
lazarenkoalexey Mar 8, 2022
6982b5f
WP-8 [WP Standalone Multiregional] LE for multiregion deployment
lazarenkoalexey Mar 8, 2022
6d1919e
WP-8 [WP Standalone Multiregional] LE for multiregion deployment
lazarenkoalexey Mar 8, 2022
956a945
WP-8 [WP Standalone Multiregional] LE for multiregion deployment
lazarenkoalexey Mar 14, 2022
886fe0e
WP-8 [WP Standalone Multiregional] LE for multiregion deployment
lazarenkoalexey Mar 16, 2022
268c42f
WP-8 [WP Standalone Multiregional] LE for multiregion deployment
lazarenkoalexey Mar 17, 2022
ae078e4
WP-8 [WP Standalone Multiregional] LE for multiregion deployment
lazarenkoalexey Mar 18, 2022
1ee6121
WP-8 [WP Standalone Multiregional] LE for multiregion deployment
lazarenkoalexey Mar 18, 2022
47f211a
WP-8 [WP Standalone Multiregional] LE for multiregion deployment
lazarenkoalexey Mar 18, 2022
6e319fa
WP-8 [WP Standalone Multiregional] LE for multiregion deployment
lazarenkoalexey Mar 18, 2022
817fdb2
WP-189 [Elastic WordPress Edition][Multiregion][LE] env has test ssl …
lazarenkoalexey Apr 14, 2022
5c06b74
WP-8 [WP Standalone Multiregional] LE for multiregion deployment
lazarenkoalexey Jul 19, 2022
aef8482
removed test flag
lazarenkoalexey Jul 19, 2022
48ada50
added custom domains to another cluster environment
lazarenkoalexey Jul 20, 2022
223f02a
WP-8 [WP Standalone Multiregional] LE for multiregion deployment
lazarenkoalexey Jul 21, 2022
0a9ed5a
WP-8 [WP Standalone Multiregional] LE for multiregion deployment
lazarenkoalexey Aug 12, 2022
3ae0993
changed baseUrl
lazarenkoalexey Dec 15, 2022
1fed566
Merge branch 'stage' into multi
lazarenkoalexey Dec 15, 2022
90c5e10
Merge pull request #205 from lazarenkoalexey/multi
lazarenkoalexey Dec 15, 2022
069329a
changed baseUrl
lazarenkoalexey Dec 21, 2022
d1754ac
JE-64706 [Let's Encrypt] Failed domains cause "too many failed author…
lazarenkoalexey Dec 22, 2022
3aa1614
Stage (#239) (#240)
lazarenkoalexey Dec 22, 2022
1b03540
Merge remote-tracking branch 'origin/stage' into stage
Mar 27, 2023
ac94b0e
JE-65967 [LE] Improve le logs while generating SSL certs
Mar 27, 2023
360b933
JE-65967 [LE] Improve le logs while generating SSL certs
Mar 27, 2023
48f1dbb
JE-65967 [LE] Improve le logs while generating SSL certs
Mar 28, 2023
9fce64e
JE-65967 [LE] Improve le logs while generating SSL certs
Mar 28, 2023
d6ebced
JE-65967 [LE] Improve le logs while generating SSL certs
Mar 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 25 additions & 13 deletions scripts/generate-ssl-cert.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ WRONG_WEBROOT_ERROR=25
UPLOAD_CERTS_ERROR=26
TIME_OUT_ERROR=27
NO_VALID_IP_ADDRESSES=28
UNEXPECTED_END_FILE=29
counter=1

[ -f "${SETTINGS}" ] && source "${SETTINGS}" || { echo "No settings available" ; exit 3 ; }
Expand Down Expand Up @@ -62,56 +63,66 @@ result_code=$GENERAL_RESULT_ERROR;
while [ "$result_code" != "0" ]
do
[[ -z $domain ]] && break;
LOG_FILE=$LOG_FILE"-"$counter
[[ $counter -eq '5' ]] && break;
LOOP_LOG_FILE=$LOG_FILE"-"$counter

resp=$($DIR/opt/letsencrypt/acme.sh --issue $params $test_params --listen-v6 --domain $domain --nocron -f --log-level 2 --log $LOG_FILE 2>&1)
resp=$($DIR/opt/letsencrypt/acme.sh --issue $params $test_params --listen-v6 --domain $domain --nocron -f --log-level 2 --log $LOOP_LOG_FILE 2>&1)

grep -q 'Cert success' $LOG_FILE && grep -q "BEGIN CERTIFICATE" $LOG_FILE && result_code=0 || result_code=$GENERAL_RESULT_ERROR
grep -q 'Cert success' $LOOP_LOG_FILE && grep -q "BEGIN CERTIFICATE" $LOOP_LOG_FILE && result_code=0 || result_code=$GENERAL_RESULT_ERROR

[[ "$result_code" == "$GENERAL_RESULT_ERROR" ]] && {
error=$(sed -rn 's/.*\s(.*)(DNS problem: .*?)",\"status.*/\2/p' $LOG_FILE | sed '$!d')
error=$(sed -rn 's/.*\s(.*)(DNS problem: .*?)",\"status.*/\2/p' $LOOP_LOG_FILE | sed '$!d')
[[ ! -z $error ]] && invalid_domain=$(echo $error | sed -rn 's/.* (.*) - .*/\1/p')

[[ -z $error ]] && {
error=$(sed -rn 's/.*\s(.*)(Invalid response from https?:\/\/.*).*/\2/p' $LOG_FILE | sed '$!d')
error=$(sed -rn 's/.*\s(.*)(Invalid response from https?:\/\/.*).*/\2/p' $LOOP_LOG_FILE | sed '$!d')
[[ ! -z $error ]] && invalid_domain=$(echo $error | sed -rn 's|(.+)addressesResolved|\1|p' | sed -rn 's|(.+)hostname.*|\1|p' | sed -rn 's|.*hostname\"\:\"([^\"]*).*|\1|p')
[[ -z $invalid_domain ]] && invalid_domain=$(echo $error | sed -rn 's|(.+)addressesResolved|\1|p' | sed -rn 's|.*hostname\":\"(.*)|\1|p' | sed -rn 's|\",.*||p')
}

[[ -z $error ]] && {
error=$(sed -rn 's/.*\s(.*)(Verify error:)/\1/p' $LOG_FILE | sed '$!d')
error=$(sed -rn 's/.*\s(.*)(Verify error:)/\1/p' $LOOP_LOG_FILE | sed '$!d')
[[ ! -z $error ]] && invalid_domain=$(echo $error | sed "s/:.*//")
}

[[ -z $error ]] && {
error=$(sed -rn 's/.*(Cannot issue for .*)",/\1/p' $LOG_FILE | sed '$!d')
error=$(sed -rn 's/.*(Cannot issue for .*)",/\1/p' $LOOP_LOG_FILE | sed '$!d')
invalid_domain=$(echo $error | sed -rn 's/Cannot issue for \\\"(.*)\\\":.*/\1/p')
}

[[ -z $error ]] && {
error=$(sed -rn 's/.*\s(.*)(Fetching https?:\/\/.*): Error getting validation data.*/\2/p' $LOG_FILE | sed '$!d')
error=$(sed -rn 's/.*\s(.*)(Fetching https?:\/\/.*): Error getting validation data.*/\2/p' $LOOP_LOG_FILE | sed '$!d')
invalid_domain=$(echo $error | sed -rn 's/Fetching https?:\/\/(.*)\/.well-known.*/\1/p')
}

[[ -z $error ]] && {
error=$(sed -rn 's|.*"detail":"(No valid IP addresses found [^"]+)".*|\1|p' $LOG_FILE | sed '$!d')
error=$(sed -rn 's|.*"detail":"(No valid IP addresses found [^"]+)".*|\1|p' $LOOP_LOG_FILE | sed '$!d')
[[ -z $error ]] && {
error=$(sed -rn 's|.*"detail":"(no valid A records found for [^;]+).*|\1|p' $LOG_FILE | sed '$!d')
error=$(sed -rn 's|.*"detail":"(no valid A records found for [^;]+).*|\1|p' $LOOP_LOG_FILE | sed '$!d')
}
invalid_domain=$(echo $error | sed -rn 's/.*for (.*)/\1/p')
[[ ! -z $error ]] && no_valid_ip=true
}

[[ -z $error ]] && {
error=$(sed -rn 's/.*(Error creating new order \:\: )(.*)\"\,/\2/p' $LOG_FILE | sed '$!d');
error=$(sed -rn 's/.*(Error creating new order \:\: )(.*)\"\,/\2/p' $LOOP_LOG_FILE | sed '$!d');
[[ ! -z $error ]] && {
rate_limit_exceeded=true;
break;
}
}

all_invalid_domains_errors+=$error";"
all_invalid_domains+=$invalid_domain" "
[[ -z $error ]] && {
grep -q "syntax error: unexpected end of file" <<< $resp && {
unexpected_end_file=true;
break;
}
}

[[ ! -z "$error" ]] && {
all_invalid_domains_errors+=$error";";
all_invalid_domains+=$invalid_domain" ";
}

domain=$(echo $domain | sed 's/'${invalid_domain}'\(\s-d\s\)\?//')
domain=$(echo $domain | sed "s/\s-d$//")
Expand Down Expand Up @@ -148,6 +159,7 @@ fi
[[ $timed_out == true ]] && exit $TIME_OUT_ERROR;
[[ $no_valid_ip == true ]] && { echo "$error"; exit $NO_VALID_IP_ADDRESSES; }
[[ $rate_limit_exceeded == true ]] && { echo "$error"; exit $TOO_MANY_CERTS; }
[[ $unexpected_end_file == true ]] && { echo "$resp"; exit $UNEXPECTED_END_FILE; }
[[ $result_code != "0" ]] && { echo "$all_invalid_domains_errors"; exit $GENERAL_RESULT_ERROR; }

#To be sure that r/w access
Expand Down
21 changes: 17 additions & 4 deletions scripts/ssl-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ function SSLManager(config) {
UPLOADER_ERROR = 12006,
READ_TIMED_OUT = 12007,
NO_VALID_IP_ADDRESSES = 12008,
UNEXPECTED_END_FILE = 12009,
VALIDATION_SCRIPT = "validation.sh",
SHELL_CODES = {},
INSTALL_LE_SCRIPT = "install-le.sh",
Expand Down Expand Up @@ -1098,6 +1099,7 @@ function SSLManager(config) {
SHELL_CODES[UPLOADER_ERROR] = 26;
SHELL_CODES[READ_TIMED_OUT] = 27;
SHELL_CODES[NO_VALID_IP_ADDRESSES] = 28;
SHELL_CODES[UNEXPECTED_END_FILE] = 29;
};

me.generateSslCerts = function generateSslCerts() {
Expand Down Expand Up @@ -1245,6 +1247,16 @@ function SSLManager(config) {
};
}

if (resp.result && resp.result == UNEXPECTED_END_FILE) {
return {
result: UNEXPECTED_END_FILE,
error: resp.response,
response: resp.response,
type: "warning",
message: resp.response
};
}

return resp;
};

Expand Down Expand Up @@ -1294,12 +1306,13 @@ function SSLManager(config) {
out = resp.error + resp.errOut + resp.out;

if (resp) {
if (resp.exitStatus == SHELL_CODES[WRONG_DNS_CUSTOM_DOMAINS]) return { result: WRONG_DNS_CUSTOM_DOMAINS, response: resp.out}
if (resp.exitStatus == SHELL_CODES[INVALID_WEBROOT_DIR]) return { result: INVALID_WEBROOT_DIR}
if (resp.exitStatus == SHELL_CODES[UPLOADER_ERROR]) return { result: UPLOADER_ERROR}
if (resp.exitStatus == SHELL_CODES[READ_TIMED_OUT]) return { result: READ_TIMED_OUT}
if (resp.exitStatus == SHELL_CODES[WRONG_DNS_CUSTOM_DOMAINS]) return { result: WRONG_DNS_CUSTOM_DOMAINS, response: resp.out }
if (resp.exitStatus == SHELL_CODES[INVALID_WEBROOT_DIR]) return { result: INVALID_WEBROOT_DIR }
if (resp.exitStatus == SHELL_CODES[UPLOADER_ERROR]) return { result: UPLOADER_ERROR }
if (resp.exitStatus == SHELL_CODES[READ_TIMED_OUT]) return { result: READ_TIMED_OUT }
if (resp.exitStatus == SHELL_CODES[NO_VALID_IP_ADDRESSES]) return { result: NO_VALID_IP_ADDRESSES, response: resp.out }
if (resp.exitStatus == SHELL_CODES[RATE_LIMIT_EXCEEDED]) return { result: RATE_LIMIT_EXCEEDED, response: resp.out }
if (resp.exitStatus == SHELL_CODES[UNEXPECTED_END_FILE]) return { result: UNEXPECTED_END_FILE, response: resp.out }
}

//just cutting "out" for debug logging because it's too long in SSL generation output
Expand Down