diff --git a/UI/includes/enrollment.php b/UI/includes/enrollment.php index 9c2ea93..a993485 100644 --- a/UI/includes/enrollment.php +++ b/UI/includes/enrollment.php @@ -532,12 +532,19 @@ EOF; * Add OpenZiti GPG key with enhanced error handling for PHP execution environment */ private function addOpenZitiGpgKey() { - $this->reportProgress('INSTALL', 'Downloading OpenZiti GPG key...'); - - // Method 1: Try the original piped command with enhanced environment $gpgKeyUrl = 'https://get.openziti.io/tun/package-repos.gpg'; $gpgKeyPath = '/usr/share/keyrings/openziti.gpg'; + // First, check if GPG key already exists and is valid + if (file_exists($gpgKeyPath) && filesize($gpgKeyPath) > 0) { + $this->reportProgress('INSTALL', 'OpenZiti GPG key already exists (' . filesize($gpgKeyPath) . ' bytes), skipping installation'); + logMessage('INFO', 'GPG key already exists at: ' . $gpgKeyPath); + return true; + } + + $this->reportProgress('INSTALL', 'Downloading OpenZiti GPG key...'); + + // Method 1: Try the original piped command with enhanced environment // First, try the enhanced piped command with explicit environment $envCommand = 'export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" && export HOME="/root" && export GNUPGHOME="/root/.gnupg"'; $gpgCommand = $envCommand . ' && curl -sSLf ' . $gpgKeyUrl . ' | gpg --dearmor --output ' . $gpgKeyPath;