feat: Add "Skip certificate verification" option for agent install commands

Adds a checkbox in Settings → Host Agents that enables insecure mode for
users running Pulse behind self-signed HTTPS certificates.

When enabled:
- Adds -k flag to curl commands for downloading the install script
- Adds --insecure flag to the agent for connecting back to Pulse

Related to #806
This commit is contained in:
rcourtman 2025-12-03 14:15:17 +00:00
parent d3f22f06bf
commit 4585db8a9d

View file

@ -108,6 +108,7 @@ export const UnifiedAgents: Component = () => {
const [lookupError, setLookupError] = createSignal<string | null>(null); const [lookupError, setLookupError] = createSignal<string | null>(null);
const [lookupLoading, setLookupLoading] = createSignal(false); const [lookupLoading, setLookupLoading] = createSignal(false);
const [enableDocker, setEnableDocker] = createSignal(false); // Default to false - user must opt-in for Docker monitoring const [enableDocker, setEnableDocker] = createSignal(false); // Default to false - user must opt-in for Docker monitoring
const [insecureMode, setInsecureMode] = createSignal(false); // For self-signed certificates (issue #806)
createEffect(() => { createEffect(() => {
if (requiresToken()) { if (requiresToken()) {
@ -235,9 +236,11 @@ export const UnifiedAgents: Component = () => {
}; };
const getDockerFlag = () => enableDocker() ? ' --enable-docker' : ''; const getDockerFlag = () => enableDocker() ? ' --enable-docker' : '';
const getInsecureFlag = () => insecureMode() ? ' --insecure' : '';
const getCurlInsecureFlag = () => insecureMode() ? '-k' : '';
const getUninstallCommand = () => { const getUninstallCommand = () => {
return `curl -fsSL ${pulseUrl()}/install.sh | sudo bash -s -- --uninstall`; return `curl ${getCurlInsecureFlag()}-fsSL ${pulseUrl()}/install.sh | sudo bash -s -- --uninstall`;
}; };
// Track previously seen host types to prevent flapping when one source temporarily has no data // Track previously seen host types to prevent flapping when one source temporarily has no data
@ -341,7 +344,7 @@ export const UnifiedAgents: Component = () => {
const getUpgradeCommand = (_hostname: string) => { const getUpgradeCommand = (_hostname: string) => {
const token = resolvedToken(); const token = resolvedToken();
return `curl -fsSL ${pulseUrl()}/install.sh | sudo bash -s -- --url ${pulseUrl()} --token ${token}`; return `curl ${getCurlInsecureFlag()}-fsSL ${pulseUrl()}/install.sh | sudo bash -s -- --url ${pulseUrl()} --token ${token}${getInsecureFlag()}`;
}; };
const handleRemoveAgent = async (id: string, type: 'host' | 'docker') => { const handleRemoveAgent = async (id: string, type: 'host' | 'docker') => {
@ -459,6 +462,15 @@ export const UnifiedAgents: Component = () => {
/> />
Enable Docker monitoring Enable Docker monitoring
</label> </label>
<label class="flex items-center gap-2 text-sm text-gray-700 dark:text-gray-300 cursor-pointer" title="Skip TLS certificate verification (for self-signed certificates)">
<input
type="checkbox"
checked={insecureMode()}
onChange={(e) => setInsecureMode(e.currentTarget.checked)}
class="rounded border-gray-300 text-blue-600 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700"
/>
Skip certificate verification
</label>
</div> </div>
<div class="space-y-4"> <div class="space-y-4">
@ -474,6 +486,10 @@ export const UnifiedAgents: Component = () => {
{(snippet) => { {(snippet) => {
const copyCommand = () => { const copyCommand = () => {
let cmd = snippet.command.replace(TOKEN_PLACEHOLDER, resolvedToken()); let cmd = snippet.command.replace(TOKEN_PLACEHOLDER, resolvedToken());
// Insert -k flag for curl if insecure mode enabled (issue #806)
if (insecureMode() && cmd.includes('curl -fsSL')) {
cmd = cmd.replace('curl -fsSL', 'curl -kfsSL');
}
// Append docker flag if enabled // Append docker flag if enabled
if (enableDocker()) { if (enableDocker()) {
// For PowerShell, we need to handle the env var or args differently // For PowerShell, we need to handle the env var or args differently
@ -491,6 +507,10 @@ export const UnifiedAgents: Component = () => {
cmd += getDockerFlag(); cmd += getDockerFlag();
} }
} }
// Append insecure flag for agent if enabled
if (insecureMode() && !cmd.includes('$env:') && !cmd.includes('irm')) {
cmd += getInsecureFlag();
}
return cmd; return cmd;
}; };