修正 SSL 憑證拼接換行問題

This commit is contained in:
2026-04-16 07:34:13 +08:00
parent 7a8436db47
commit 7965c234df

View File

@@ -36,10 +36,28 @@ build_cert_bundle() {
exit 1
fi
cat "${cert_path}" "${chain_path}" > "${GENERATED_CERT_PATH}"
normalize_pem_file "${cert_path}" > "${GENERATED_CERT_PATH}"
normalize_pem_file "${chain_path}" >> "${GENERATED_CERT_PATH}"
cp "${key_path}" "${GENERATED_KEY_PATH}"
}
normalize_pem_file() {
pem_path="$1"
awk '
{
sub(/\r$/, "")
print
has_content = 1
}
END {
if (has_content) {
print ""
}
}
' "${pem_path}"
}
write_nginx_config() {
cat > /etc/nginx/conf.d/default.conf <<EOF
server {