From 90a64a1b22d19603fe78a6814bfd52683b40d4a0 Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Fri, 29 May 2026 02:52:57 +0200 Subject: [PATCH] fix(ssl): prompt before setting IP cert path for panel The IP certificate flow auto-set the panel cert path silently, unlike the domain and Cloudflare flows which ask first. Add the same "Would you like to set this certificate for the panel? (y/n)" prompt so the IP flow is consistent and only configures the panel on confirmation. --- x-ui.sh | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/x-ui.sh b/x-ui.sh index d62532e7..af22c1ca 100644 --- a/x-ui.sh +++ b/x-ui.sh @@ -1371,24 +1371,30 @@ ssl_cert_issue_for_ip() { chmod 600 $certPath/privkey.pem 2> /dev/null chmod 644 $certPath/fullchain.pem 2> /dev/null - # Set certificate paths for the panel + # Prompt user to set panel paths after successful certificate installation local webCertFile="${certPath}/fullchain.pem" local webKeyFile="${certPath}/privkey.pem" - if [[ -f "$webCertFile" && -f "$webKeyFile" ]]; then - ${xui_folder}/x-ui cert -webCert "$webCertFile" -webCertKey "$webKeyFile" - LOGI "Certificate configured for panel" - LOGI " - Certificate File: $webCertFile" - LOGI " - Private Key File: $webKeyFile" - LOGI " - Validity: ~6 days (auto-renews via acme.sh cron)" - echo -e "${green}Access URL: https://${server_ip}:${existing_port}${existing_webBasePath}${plain}" - LOGI "Panel will restart to apply SSL certificate..." - restart - return 0 + read -rp "Would you like to set this certificate for the panel? (y/n): " setPanel + if [[ "$setPanel" == "y" || "$setPanel" == "Y" ]]; then + if [[ -f "$webCertFile" && -f "$webKeyFile" ]]; then + ${xui_folder}/x-ui cert -webCert "$webCertFile" -webCertKey "$webKeyFile" + LOGI "Panel paths set for IP: $server_ip" + LOGI " - Certificate File: $webCertFile" + LOGI " - Private Key File: $webKeyFile" + LOGI " - Validity: ~6 days (auto-renews via acme.sh cron)" + echo -e "${green}Access URL: https://${server_ip}:${existing_port}${existing_webBasePath}${plain}" + LOGI "Panel will restart to apply SSL certificate..." + restart + else + LOGE "Error: Certificate or private key file not found for IP: $server_ip." + return 1 + fi else - LOGE "Certificate files not found after installation" - return 1 + LOGI "Skipping panel path setting." fi + + return 0 } ssl_cert_issue() {