Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
feat(monitoring): alert on certificate validity
rcourtman198c66c6c459
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.mdindex 8f6db856a4..f8e4d10ddb 100644--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md@@ -90,6 +90,12 @@ agent-authored check time as observation metadata. That receipt timestamp isprobe-result liveness only: lifecycle consumers must not reinterpret it as ahost heartbeat, enrollment renewal, command-channel readiness, or fleet-updateobservation.+An HTTPS probe result may carry a secret-free certificate observation alongside+the outcome. The host agent must use the shared availability probe and report+shape so local and remote checks derive identical trust vocabulary. Certificate+identity, validity, and trust are observation payloads only. They do not renew+the target lease, agent enrollment, host heartbeat, or command readiness beyond+the accepted report's existing server-receipt evidence.## Canonical Filesdiff --git a/docs/release-control/v6/internal/subsystems/alerts.md b/docs/release-control/v6/internal/subsystems/alerts.mdindex 27a1998c49..dcf85fb8ed 100644--- a/docs/release-control/v6/internal/subsystems/alerts.md+++ b/docs/release-control/v6/internal/subsystems/alerts.md@@ -61,6 +61,12 @@ Availability incident and alert identity belongs to the source-ownedmachine, but it must not copy the check incident onto that machine or create asecond alert lifecycle. Failure, recovery, history, acknowledgement, andnotification routing therefore remain stable under relinking and restart.+Certificate validity uses that same source-owned incident lifecycle. Codes+prefixed `certificate_` map to alert type `certificate`: expiry-window incidents+are warning, while expired, not-yet-valid, and untrusted incidents are critical.+A self-signed certificate is not an untrusted-chain alert. Certificate alerts+reuse canonical confirmation, acknowledgement, history, recovery, schedule,+intent, and notification routing and must not create a parallel delivery path.Linux memory thresholds consume only canonical cache-aware usage. An explicitusage-unavailable sample, a non-finite percentage, or contradictoryused/free/total evidence must not open or clear a memory alert. If such adiff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex 14e92fa3cb..fa20b1f248 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -1245,6 +1245,14 @@ payload shape change when the portal presents compact client rows.frontend-primitives' `CalloutCard` for shared settings callout chrome;API contracts own the target CRUD/test payload semantics and endpointrouting, not local colored alert shells.+ HTTPS target payloads additively carry+ `certificateMonitoringDisabled` and `certificateExpiryWarningDays`.+ Monitoring is on by default when the explicit opt-out is absent, and the+ effective warning window defaults to 30 days. Certificate settings are+ invalid on non-HTTPS targets. Saved and unsaved test responses may include+ the same secret-free `certificate` observation returned by the runtime+ probe, while reachability success remains independent from trust posture so+ an operator can diagnose an untrusted but reachable endpoint.Availability target protocol vocabulary is canonicalized at the API/configboundary: clients may submit `ping` as a user-facing alias for the ICMPcheck, but saved targets, API reads, probe status, connections rows, and@@ -1264,10 +1272,11 @@ payload shape change when the portal presents compact client rows.the canonical API contract rather than a frontend-only fixture.Availability target payloads carry an optional `linkedResourceId` fieldthat, when set to a known resource id, requests the unified-resource- registry to attach the probe facet onto that resource instead of minting- a standalone `network-endpoint`. The field is advisory: the registry- still applies IP-correlation when no explicit link is provided, and a- link that would overwrite a different target's facet is ignored.+ registry to attach the probe facet onto that resource while retaining the+ source-owned `network-endpoint`. The field is authoritative and+ fail-closed: invalid or ambiguous explicit references remain unresolved and+ do not fall back to address correlation. Address correlation applies only+ when no explicit link is present.20. `frontend-modern/src/components/Settings/NodeModalAuthenticationSection.tsx` shared with `agent-lifecycle`: the node setup authentication section is both an agent lifecycle control surface and a shared API-backed install/setup contract boundary.21. `frontend-modern/src/components/Settings/NodeModalBasicInfoSection.tsx` shared with `agent-lifecycle`: the node setup basic-info section is both an agent lifecycle control surface and a shared API-backed install/setup contract boundary.22. `frontend-modern/src/components/Settings/nodeModalModel.ts` shared with `agent-lifecycle`: the pure node setup modal model is both an agent lifecycle control surface and a shared API-backed install/setup contract boundary.diff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.mdindex 11f407d7ae..648b04b1a6 100644--- a/docs/release-control/v6/internal/subsystems/monitoring.md+++ b/docs/release-control/v6/internal/subsystems/monitoring.md@@ -403,6 +403,9 @@ changes.29. `internal/monitoring/mock_metrics_history.go`30. `internal/monitoring/mock_chart_history.go`31. `internal/monitoring/availability_poller.go`+31a. `internal/availabilityprobe/probe.go`+31b. `internal/config/availability.go`+31c. `pkg/tlsutil/certificate.go`32. `internal/monitoring/scheduler.go`33. `internal/monitoring/docker_detection.go`34. `internal/monitoring/monitor_polling_containers.go`@@ -1116,6 +1119,18 @@ load from the config persistence boundary, schedule throughthe default low-overhead check, while TCP and HTTP are canonical fallbacks fordevices or runtimes where ICMP is unavailable or the useful signal is a port orweb interface.+HTTPS checks also author one canonical certificate observation from the same+probe execution. `internal/availabilityprobe` captures the presented leaf and+`pkg/tlsutil/certificate.go` derives subject, issuer, SANs, SHA-256 fingerprint,+validity bounds, hostname match, chain validity, and the bounded trust status.+Monitoring is enabled by default for HTTPS targets, may be explicitly disabled,+and uses a configurable expiry-warning window that defaults to 30 days. Expired,+not-yet-valid, and otherwise untrusted certificates produce critical provider+incidents. Certificates inside the warning window produce a warning incident.+A verified self-signed leaf is identified as `self-signed` and is exempt from+the untrusted-chain incident, while its identity and expiry remain visible.+These certificate incidents stay owned by the source `network-endpoint` and+enter the normal unified-incident alert pipeline rather than a second notifier.Supplemental records carry the saved target's optional `LinkedResourceID`forward into `AvailabilityData` so the unified-resource registry can correlateand project the probe facet onto the referenced resource. Every saved target@@ -1165,7 +1180,10 @@ the frontend-primitives-owned Standalone surface may read the same`network-endpoint` projection to show current reachability, latency, check age,and failure state without creating another monitoring provider or top-levelavailability route.-Availability targets may also be assigned to a remote host agent. While the+Availability targets may also be assigned to a remote host agent. Reachability+outcome and the optional certificate observation travel in the same bounded+report entry, and the server clones that observation before status and resource+projection so report buffers cannot alias live state. While the`external_probe` entitlement is active, a probe-assigned target is executedexclusively by its assigned agent: monitoring must not schedule or run itlocally, so the check never executes twice. The assignment is effective only fordiff --git a/docs/release-control/v6/internal/subsystems/registry.json b/docs/release-control/v6/internal/subsystems/registry.jsonindex 1b5a00795f..7291b403b1 100644--- a/docs/release-control/v6/internal/subsystems/registry.json+++ b/docs/release-control/v6/internal/subsystems/registry.json@@ -2882,6 +2882,7 @@"internal/api/ai_handlers_more_test.go","internal/api/ai_handlers_patrol_actions_additional_test.go","internal/api/audit_handlers_test.go",+ "internal/api/availability_handlers_test.go","internal/api/contract_test.go","internal/api/docker_agents_report_size_test.go","internal/api/external_probe_notifications_test.go",@@ -5199,6 +5200,7 @@"lane": "L13","contract": "docs/release-control/v6/internal/subsystems/monitoring.md","owned_prefixes": [+ "internal/availabilityprobe/","internal/fleethealth/","internal/monitoring/","internal/storagehealth/",@@ -5207,6 +5209,7 @@],"owned_files": ["docker-entrypoint.sh",+ "internal/config/availability.go","internal/config/docker_metadata.go","internal/config/guest_metadata.go","internal/config/host_continuity.go",@@ -5235,7 +5238,8 @@"pkg/proxmox/client.go","pkg/proxmox/cluster_client.go","pkg/proxmox/io_counters.go",- "pkg/proxmox/zfs.go"+ "pkg/proxmox/zfs.go",+ "pkg/tlsutil/certificate.go"],"verification": {"allow_same_subsystem_tests": true,@@ -5245,6 +5249,27 @@],"require_explicit_path_policy_coverage": true,"path_policies": [+ {+ "id": "availability-certificate-runtime",+ "label": "availability and certificate monitoring proof",+ "match_prefixes": [+ "internal/availabilityprobe/"+ ],+ "match_files": [+ "internal/config/availability.go",+ "pkg/tlsutil/certificate.go"+ ],+ "allow_same_subsystem_tests": false,+ "test_prefixes": [],+ "exact_files": [+ "internal/availabilityprobe/probe_test.go",+ "internal/config/availability_test.go",+ "internal/monitoring/availability_poller_test.go",+ "internal/monitoring/availability_probe_agent_test.go",+ "pkg/agents/host/report_test.go",+ "pkg/tlsutil/certificate_test.go"+ ]+ },{"id": "discovery-provider-runtime","label": "monitoring discovery provider proof",@@ -5287,7 +5312,8 @@"internal/monitoring/monitor_host_agent_removal_lifecycle_test.go","internal/monitoring/monitor_host_agents_test.go","internal/monitoring/monitor_package_updates_test.go",- "internal/unifiedresources/code_standards_test.go"+ "internal/unifiedresources/code_standards_test.go",+ "pkg/agents/host/report_test.go"]},{@@ -7192,6 +7218,7 @@"internal/unifiedresources/canonical_identity_test.go","internal/unifiedresources/canonical_ids_types_test.go","internal/unifiedresources/ceph_pool_health_contract_test.go",+ "internal/unifiedresources/clone_test.go","internal/unifiedresources/code_standards_test.go","internal/unifiedresources/identity_test.go","internal/unifiedresources/ids_test.go",@@ -7338,6 +7365,7 @@"frontend-modern/src/components/Infrastructure/__tests__/ResourceCorrelationSummary.test.tsx","frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.discovery.test.ts","frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.history.test.tsx",+ "frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.service-cards.test.tsx","frontend-modern/src/components/Infrastructure/__tests__/resourceDetailDrawerIdentityModel.test.ts","frontend-modern/src/components/Infrastructure/__tests__/resourceDetailDrawerOperationalModel.test.ts","frontend-modern/src/components/Infrastructure/__tests__/resourceDetailDrawerTrueNASModel.test.ts",diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.mdindex f2981b021b..e62b481a78 100644--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md@@ -1465,6 +1465,10 @@ recovery scope, or a storage/recovery-owned secret source.than Standalone Machines; storage and recovery must treat the row asliveness context unless a separate storage/recovery-owned relationship tiesit to backup or restore evidence.+ Certificate identity, trust, hostname validity, expiry, and any+ `certificate_*` incident on those availability facets remain monitoring and+ alerts context. They do not prove storage encryption, backup integrity,+ repository authenticity, protection coverage, or restore readiness.33. Keep infrastructure summary chart bucketing and short response caching presentation-only on the adjacent shared API boundary. When `internal/api/router.go` normalizes mixed-cadence infrastructure history into equal-time summary buckets or serves a cached summary payload for repeated operator-facing summary-card requests, storage and recovery may consume the resulting visual context only; they must not reinterpret those normalized chart samples, cached timestamps, or cache hits as recovery freshness windows, backup cadence, or restore evidence.The same router may wire the adjacent server-owned agent commandauthorization verifier, but storage/recovery must not treat an approval id,diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.mdindex 12e2caea60..e4d0a20cfb 100644--- a/docs/release-control/v6/internal/subsystems/unified-resources.md+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md@@ -2116,6 +2116,13 @@ The owning detail renders protocol, full target, latest result, latency,freshness, and last observation for every attached check. Expired successfulevidence is `stale`, not `Up` or `Responding normally`; an unobserved check is`Not checked`, not `Down`.+For HTTPS checks the same availability facet additively preserves certificate+monitoring policy and the canonical certificate observation. Resource clones+must deep-copy certificate SAN slices. The owning availability card on both the+source endpoint and any linked resource overview renders trust, subject, expiry,+hostname match, issuer, and a bounded SHA-256 fingerprint preview. Certificate+incidents remain on the source-owned endpoint and are not duplicated onto the+linked resource during projection.Frontend primitives owns Machines as the operational presentation for thosesame agentless checks; unified resources owns the projection contract consumedthere. `StandalonePageSurface.tsx` must fetch both `agent` anddiff --git a/frontend-modern/browser-verification.json b/frontend-modern/browser-verification.jsonindex bd5066e5ca..7ee099b018 100644--- a/frontend-modern/browser-verification.json+++ b/frontend-modern/browser-verification.json@@ -1,78 +1,48 @@{"version": 1,- "base_sha": "328319a8bcd75e8ee838dd09d7064d72fb22afcb",- "verified_at": "2026-08-06T08:25:26Z",+ "base_sha": "2be0ec649487512d61a09b743e88cc82973e0d04",+ "verified_at": "2026-08-06T08:40:31Z","result": "passed","changed_paths": [- "frontend-modern/src/components/AI/AICostDashboard.tsx",- "frontend-modern/src/components/Settings/DockerRuntimeSettingsCard.tsx",- "frontend-modern/src/components/Settings/SettingsPageShell.tsx"+ "frontend-modern/src/api/availabilityTargets.ts",+ "frontend-modern/src/components/Infrastructure/AvailabilityProbeStatusCard.tsx",+ "frontend-modern/src/components/Infrastructure/ResourceDetailDrawerOverviewTab.tsx",+ "frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/AvailabilityTargetSlot.tsx",+ "frontend-modern/src/types/resource.ts"],"content_sha256": {- "frontend-modern/src/components/AI/AICostDashboard.tsx": "a49cfbaf3d58a5c1425176e43e5b1878c217ba2c863d087c899df446c56cc44b",- "frontend-modern/src/components/Settings/DockerRuntimeSettingsCard.tsx": "fbdf5dd1a5aed7c9dfbeb14783dfac2ae50397cde7ca48668632c013d6190414",- "frontend-modern/src/components/Settings/SettingsPageShell.tsx": "8da076ef631f164e01e72760c39bb05864401fcad24f02993635f3ba58412fa8"+ "frontend-modern/src/api/availabilityTargets.ts": "8a748f332a76b2cfa4a3a3dfc0e400fe9593ec7f410ad1388927fd769126b409",+ "frontend-modern/src/components/Infrastructure/AvailabilityProbeStatusCard.tsx": "29c97f569f6ba677d954f4045a870f3166761dcd852a20e2e4460d8c30861602",+ "frontend-modern/src/components/Infrastructure/ResourceDetailDrawerOverviewTab.tsx": "5e270c80ef9b1b1a6f6fbd8241c81ad5e710dbc02115f846809278322c160307",+ "frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/AvailabilityTargetSlot.tsx": "39778a7e90a10fead774d71cc5eab26e0d9232047cde2484b7588ce6c04f8611",+ "frontend-modern/src/types/resource.ts": "39c5b13dae6642932c68bb31de77297272228a8ca7c72d115fa8b84eace9e157"},"routes": [- "/settings/infrastructure","/settings/monitoring/availability",- "/settings/pulse-intelligence/provider",- "/settings/pulse-intelligence/patrol",- "/settings/pulse-intelligence/assistant",- "/settings/system-general",- "/settings/system-network",- "/settings/system-updates",- "/settings/system-recovery",- "/settings/system-relay",- "/settings/support/diagnostics",- "/settings/support/logs",- "/settings/security-overview",- "/settings/security/api",- "/settings/security-auth",- "/settings/security-sso",- "/alerts/overview",- "/alerts/history",- "/alerts/thresholds/proxmox",- "/alerts/thresholds/vmware",- "/alerts/notifications",- "/alerts/schedule",- "/actions",- "/patrol"+ "/docker/swarm"],"viewports": [{"width": 1280,"height": 820},- {- "width": 768,- "height": 820- },{"width": 390,- "height": 820- },- {- "width": 320,- "height": 820+ "height": 844}],"states": [- "every visible Settings destination reached through the real mobile settings navigator",- "Provider Usage and Spend with all five cost ranges visible",- "General Docker and Podman update setting with its environment-variable hint",- "mobile Settings page label before and after client-side navigation",- "Alerts top-level and threshold tab strips with beginning, middle, and final selections",- "Actions Open and History views",- "Patrol attention workbench"+ "HTTPS availability target editor with certificate monitoring enabled by default",+ "certificate expiry warning window at its 30 day default",+ "certificate monitoring opted out with the warning input disabled",+ "linked HTTPS availability target in the Docker Swarm resource journey"],"interactions": [- "navigated every visible Settings destination through the 320 pixel sidebar and checked interactive controls for clipped bounds",- "selected 1 year, 1 day, and 30 day provider cost ranges and confirmed each remained fully visible with zero document overflow",- "confirmed the mobile Settings active-page label updates from Provider and Models to General without retaining the previous destination",- "visually inspected the reflowed provider usage header and verified its five buttons exactly fit the available card width",- "visually inspected the General update setting and confirmed its title, toggle, description, and long environment token remain inside the card",- "checked Settings at 320, 390, 768, and 1280 pixels with zero page overflow",- "checked Alerts, Actions, and Patrol at 320 pixels for hidden filters or actions and exercised Action History"+ "opened the add availability check dialog and selected HTTPS",+ "toggled certificate monitoring off and on and confirmed the expiry input disabled and re-enabled",+ "inspected the desktop dialog at 1280 by 820 pixels",+ "inspected the narrow dialog and TLS controls at 390 by 844 pixels with zero horizontal overflow",+ "navigated to the linked Docker Swarm service journey and confirmed the HTTPS availability target projection",+ "checked the browser console after the changed journeys and found no errors"]}diff --git a/frontend-modern/src/api/availabilityTargets.ts b/frontend-modern/src/api/availabilityTargets.tsindex 6e9160ad4b..78e1d7f205 100644--- a/frontend-modern/src/api/availabilityTargets.ts+++ b/frontend-modern/src/api/availabilityTargets.ts@@ -1,4 +1,5 @@import { apiFetchJSON } from '@/utils/apiClient';+import type { ResourceCertificateObservation } from '@/types/resource';const AVAILABILITY_TARGETS_PATH = '/api/availability-targets';@@ -26,6 +27,7 @@ export interface AvailabilityProbeStatus {* Absent (omitempty) when the local Pulse server ran the check.*/probeAgentId?: string;+ certificate?: ResourceCertificateObservation;}export interface AvailabilityTarget {@@ -44,6 +46,8 @@ export interface AvailabilityTarget {pollIntervalSeconds?: number;timeoutMillis?: number;failureThreshold?: number;+ certificateMonitoringDisabled?: boolean;+ certificateExpiryWarningDays?: number;/*** Host agent that runs this check. Empty string means the local Pulse* server. Assigning a non-empty value requires the `external_probe`@@ -59,6 +63,7 @@ export interface AvailabilityTestResponse {latencyMillis: number;outcome?: 'reachable' | 'unreachable' | 'indeterminate' | string;error?: string;+ certificate?: ResourceCertificateObservation;}export class AvailabilityTargetsAPI {diff --git a/frontend-modern/src/components/Infrastructure/AvailabilityProbeStatusCard.tsx b/frontend-modern/src/components/Infrastructure/AvailabilityProbeStatusCard.tsxindex 43cf2eb2ae..e4144e0209 100644--- a/frontend-modern/src/components/Infrastructure/AvailabilityProbeStatusCard.tsx+++ b/frontend-modern/src/components/Infrastructure/AvailabilityProbeStatusCard.tsx@@ -73,6 +73,38 @@ export function AvailabilityProbeStatusCard(props: AvailabilityProbeStatusCardPrif (/refused|unreachable|no route/i.test(err)) return 'Unreachable';return err.length > 40 ? `${err.slice(0, 40)}…` : err;};+ const certificate = () => props.availability.certificate;+ const certificateTrust = () => {+ switch (certificate()?.trustStatus) {+ case 'trusted':+ return { label: 'Trusted', tone: 'success' as const };+ case 'self-signed':+ return { label: 'Self-signed', tone: 'neutral' as const };+ case 'expired':+ return { label: 'Expired', tone: 'danger' as const };+ case 'not-yet-valid':+ return { label: 'Not yet valid', tone: 'danger' as const };+ case 'untrusted':+ return { label: 'Untrusted', tone: 'danger' as const };+ default:+ return { label: 'Unknown', tone: 'neutral' as const };+ }+ };+ const certificateExpiry = () => {+ const value = certificate()?.notAfter;+ if (!value) return null;+ const expiry = new Date(value);+ if (!Number.isFinite(expiry.getTime())) return null;+ const days = Math.ceil((expiry.getTime() - Date.now()) / 86_400_000);+ const date = expiry.toLocaleDateString(undefined, {+ day: 'numeric',+ month: 'short',+ year: 'numeric',+ });+ if (days < 0) return `${date} (${Math.abs(days)}d ago)`;+ if (days === 0) return `${date} (today)`;+ return `${date} (${days}d)`;+ };return (<InfoCardFrame data-testid="availability-probe-status">@@ -152,6 +184,80 @@ export function AvailabilityProbeStatusCard(props: AvailabilityProbeStatusCardPr</div>)}</Show>+ <Show when={certificate()}>+ {(cert) => (+ <div class="mt-1.5 space-y-1.5 border-t border-base-200 pt-1.5">+ <div class="flex items-center justify-between gap-2">+ <span class="text-muted">Certificate</span>+ <span+ class="font-medium"+ classList={{+ 'text-emerald-600 dark:text-emerald-300': certificateTrust().tone === 'success',+ 'text-red-600 dark:text-red-300': certificateTrust().tone === 'danger',+ 'text-base-content': certificateTrust().tone === 'neutral',+ }}+ title={cert().trustError || undefined}+ >+ {certificateTrust().label}+ </span>+ </div>+ <Show when={cert().subject}>+ <div class="flex items-center justify-between gap-2">+ <span class="text-muted">Subject</span>+ <span class="ml-2 truncate font-medium text-base-content" title={cert().subject}>+ {cert().subject}+ </span>+ </div>+ </Show>+ <Show when={certificateExpiry()}>+ {(expiry) => (+ <div class="flex items-center justify-between gap-2">+ <span class="text-muted">Expires</span>+ <span+ class="font-medium text-base-content"+ title={`Warning window: ${props.availability.certificateExpiryWarningDays ?? 30} days`}+ >+ {expiry()}+ </span>+ </div>+ )}+ </Show>+ <div class="flex items-center justify-between gap-2">+ <span class="text-muted">Hostname</span>+ <span+ class="font-medium"+ classList={{+ 'text-emerald-600 dark:text-emerald-300': cert().hostnameValid,+ 'text-red-600 dark:text-red-300': !cert().hostnameValid,+ }}+ >+ {cert().hostnameValid ? 'Matches' : 'Mismatch'}+ </span>+ </div>+ <Show when={cert().issuer}>+ <div class="flex items-center justify-between gap-2">+ <span class="text-muted">Issuer</span>+ <span class="ml-2 truncate text-base-content" title={cert().issuer}>+ {cert().issuer}+ </span>+ </div>+ </Show>+ <Show when={cert().fingerprintSha256}>+ {(fingerprint) => (+ <div class="flex items-center justify-between gap-2">+ <span class="text-muted">SHA-256</span>+ <span+ class="ml-2 truncate font-mono text-[10px] text-base-content"+ title={fingerprint()}+ >+ {fingerprint().slice(0, 16)}…+ </span>+ </div>+ )}+ </Show>+ </div>+ )}+ </Show><Show when={isDown() && failureLabel()}><div class="flex items-start gap-1.5 mt-1.5 pt-1.5 border-t border-base-200"><AlertCircle class="h-3 w-3 text-red-500 shrink-0 mt-0.5" aria-hidden="true" />diff --git a/frontend-modern/src/components/Infrastructure/ResourceDetailDrawerOverviewTab.tsx b/frontend-modern/src/components/Infrastructure/ResourceDetailDrawerOverviewTab.tsxindex d0881c9810..0f37a414df 100644--- a/frontend-modern/src/components/Infrastructure/ResourceDetailDrawerOverviewTab.tsx+++ b/frontend-modern/src/components/Infrastructure/ResourceDetailDrawerOverviewTab.tsx@@ -48,6 +48,7 @@ import { shouldShowResourcePlatformId } from '@/utils/resourceIdentity';import { isPulseAgentPlatformResource } from '@/utils/agentResources';import { formatInteger } from './resourceDetailMappers';import { buildPbsJobHealthEvidenceModel } from './resourceDetailDrawerServiceModel';+import { AvailabilityProbeStatusCards } from './AvailabilityProbeStatusCard';import { ResourceDetailDrawerSupportDisclosure as SupportDisclosure } from './ResourceDetailDrawerSupportDisclosure';import type { UseResourceDetailDrawerStateResult } from './useResourceDetailDrawerState';import type { ResourceDetailDrawerPresentation } from './resourceDetailDrawerPresentation';@@ -440,6 +441,15 @@ export const ResourceDetailDrawerOverviewTab: Component<ResourceDetailDrawerOver</details></Show>+ <Show when={resource.availability || (resource.availabilityChecks?.length ?? 0) > 0}>+ <div class="flex flex-wrap gap-3 [&>*]:min-w-[240px] [&>*]:flex-1">+ <AvailabilityProbeStatusCards+ availability={resource.availability}+ checks={resource.availabilityChecks}+ />+ </div>+ </Show>+<div data-testid="resource-secondary-sections" class="space-y-3"><Show when={shouldRenderChangeHistorySection()}><InfoCardFrame data-testid="resource-change-history-section" class="w-full">diff --git a/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.service-cards.test.tsx b/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.service-cards.test.tsxindex 231b7a6a9c..5bbe1a24d0 100644--- a/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.service-cards.test.tsx+++ b/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.service-cards.test.tsx@@ -327,4 +327,39 @@ describe('ResourceDetailDrawer service cards', () => {expect(queryByText('Updates Available')).toBeNull();expect(queryByText('Last Check')).toBeNull();});++ it('renders linked HTTPS certificate posture in the resource overview', () => {+ const resource = baseResource({+ availabilityChecks: [+ {+ targetId: 'pulse-ui',+ address: 'pulse.example.test',+ protocol: 'https',+ enabled: true,+ available: true,+ lastChecked: new Date().toISOString(),+ certificateExpiryWarningDays: 30,+ certificate: {+ subject: 'pulse.example.test',+ issuer: 'Example CA',+ dnsNames: ['pulse.example.test'],+ notBefore: '2026-01-01T00:00:00Z',+ notAfter: '2027-01-01T00:00:00Z',+ fingerprintSha256: '0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef',+ chainValid: true,+ hostnameValid: true,+ selfSigned: false,+ trustStatus: 'trusted',+ observedAt: '2026-08-06T12:00:00Z',+ },+ },+ ],+ });++ const { getByTestId, getByText } = render(() => <ResourceDetailDrawer resource={resource} />);++ expect(getByTestId('availability-probe-status')).toBeInTheDocument();+ expect(getByText('Trusted')).toBeInTheDocument();+ expect(getByText('Example CA')).toBeInTheDocument();+ });});diff --git a/frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/AvailabilityTargetSlot.tsx b/frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/AvailabilityTargetSlot.tsxindex e70865a75b..fe63a98fda 100644--- a/frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/AvailabilityTargetSlot.tsx+++ b/frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/AvailabilityTargetSlot.tsx@@ -61,6 +61,8 @@ interface AvailabilityForm {pollIntervalSeconds: string;timeoutMillis: string;failureThreshold: string;+ monitorCertificate: boolean;+ certificateExpiryWarningDays: string;}export interface AvailabilityTargetSlotProps {@@ -96,6 +98,8 @@ const newAvailabilityForm = (pollIntervalSeconds: '60',timeoutMillis: '2000',failureThreshold: '2',+ monitorCertificate: true,+ certificateExpiryWarningDays: '30',});const formFromTarget = (target: AvailabilityTarget): AvailabilityForm => ({@@ -115,6 +119,8 @@ const formFromTarget = (target: AvailabilityTarget): AvailabilityForm => ({pollIntervalSeconds: String(target.pollIntervalSeconds ?? 60),timeoutMillis: String(target.timeoutMillis ?? 2000),failureThreshold: String(target.failureThreshold ?? 2),+ monitorCertificate: target.certificateMonitoringDisabled !== true,+ certificateExpiryWarningDays: String(target.certificateExpiryWarningDays ?? 30),});const parsePositiveInt = (value: string): number | undefined => {@@ -122,6 +128,22 @@ const parsePositiveInt = (value: string): number | undefined => {return Number.isFinite(parsed) && parsed > 0 ? parsed : undefined;};+const availabilityTestSuccessDescription = (result: AvailabilityTestResponse): string => {+ const base = `Probe reached the target in ${result.latencyMillis} ms.`;+ const certificate = result.certificate;+ if (!certificate) return base;+ const trust = certificate.trustStatus.replace('-', ' ');+ const expiry = new Date(certificate.notAfter);+ if (!Number.isFinite(expiry.getTime())) {+ return `${base} Certificate: ${trust}.`;+ }+ return `${base} Certificate: ${trust}, expires ${expiry.toLocaleDateString(undefined, {+ day: 'numeric',+ month: 'short',+ year: 'numeric',+ })}.`;+};+const payloadFromForm = (form: AvailabilityForm): AvailabilityTarget => {const port = parsePositiveInt(form.port);return {@@ -144,6 +166,9 @@ const payloadFromForm = (form: AvailabilityForm): AvailabilityTarget => {pollIntervalSeconds: parsePositiveInt(form.pollIntervalSeconds),timeoutMillis: parsePositiveInt(form.timeoutMillis),failureThreshold: parsePositiveInt(form.failureThreshold),+ certificateMonitoringDisabled: form.protocol === 'https' ? !form.monitorCertificate : false,+ certificateExpiryWarningDays:+ form.protocol === 'https' ? parsePositiveInt(form.certificateExpiryWarningDays) : 0,};};@@ -500,6 +525,38 @@ export const AvailabilityTargetSlot: Component<AvailabilityTargetSlotProps> = (p/></label></Show>+ <Show when={form().protocol === 'https'}>+ <div class="flex items-center rounded-md border border-border bg-surface-alt px-4 py-3">+ <label class="flex items-center gap-3">+ <input+ type="checkbox"+ class={formCheckbox}+ checked={form().monitorCertificate}+ onChange={(event) =>+ updateForm({ monitorCertificate: event.currentTarget.checked })+ }+ />+ <span class="text-sm text-base-content">Monitor TLS certificate validity</span>+ </label>+ </div>+ <label class={formField}>+ <span class={formLabel}>Expiry warning (days)</span>+ <input+ class={formControl}+ aria-label="Expiry warning (days)"+ inputMode="numeric"+ value={form().certificateExpiryWarningDays}+ disabled={!form().monitorCertificate}+ onInput={(event) =>+ updateForm({ certificateExpiryWarningDays: event.currentTarget.value })+ }+ placeholder="30"+ />+ <span class={formHelpText}>+ Raise an alert when the certificate enters this expiry window.+ </span>+ </label>+ </Show><Show when={form().protocol === 'udp'}><FormSelectlabel="UDP result policy"@@ -598,7 +655,7 @@ export const AvailabilityTargetSlot: Component<AvailabilityTargetSlotProps> = (presult().outcome === 'indeterminate'? `No UDP rejection was received in ${result().latencyMillis} ms; the port is open or filtered, not proven reachable.`: result().success- ? `Probe reached the target in ${result().latencyMillis} ms.`+ ? availabilityTestSuccessDescription(result()): result().error || 'Probe failed.'}/>diff --git a/frontend-modern/src/components/Settings/ConnectionEditor/__tests__/AvailabilityTargetSlot.test.tsx b/frontend-modern/src/components/Settings/ConnectionEditor/__tests__/AvailabilityTargetSlot.test.tsxindex 294807c5f1..44b4ba08a5 100644--- a/frontend-modern/src/components/Settings/ConnectionEditor/__tests__/AvailabilityTargetSlot.test.tsx+++ b/frontend-modern/src/components/Settings/ConnectionEditor/__tests__/AvailabilityTargetSlot.test.tsx@@ -217,6 +217,33 @@ describe('AvailabilityTargetSlot', () => {expect(onSaved).toHaveBeenCalledTimes(1);});+ it('enables HTTPS certificate monitoring with a 30-day warning by default', async () => {+ render(() => <AvailabilityTargetSlot onCancel={vi.fn()} onSaved={vi.fn()} />);++ fireEvent.change(screen.getByLabelText('Probe'), { target: { value: 'https' } });+ expect(screen.getByLabelText('Monitor TLS certificate validity')).toBeChecked();+ expect(screen.getByLabelText('Expiry warning (days)')).toHaveValue('30');++ fireEvent.input(screen.getByLabelText('Name'), { target: { value: 'Pulse UI' } });+ fireEvent.input(screen.getByPlaceholderText('https://service.local/status'), {+ target: { value: 'pulse.example.test' },+ });+ fireEvent.input(screen.getByLabelText('Expiry warning (days)'), {+ target: { value: '45' },+ });+ fireEvent.click(screen.getByRole('button', { name: 'Add service/device check' }));++ await waitFor(() =>+ expect(mockedCreate).toHaveBeenCalledWith(+ expect.objectContaining({+ protocol: 'https',+ certificateMonitoringDisabled: false,+ certificateExpiryWarningDays: 45,+ }),+ ),+ );+ });+describe('external probe assignment', () => {it('offers connected agent hosts and saves the assignment when licensed', async () => {resourceMocks.resources = [agentHostResource('host-edge-01', 'Edge 01')];diff --git a/frontend-modern/src/components/Workloads/__tests__/AvailabilityProbeStatusCard.test.tsx b/frontend-modern/src/components/Workloads/__tests__/AvailabilityProbeStatusCard.test.tsxindex 4229dc0a64..e9797623d6 100644--- a/frontend-modern/src/components/Workloads/__tests__/AvailabilityProbeStatusCard.test.tsx+++ b/frontend-modern/src/components/Workloads/__tests__/AvailabilityProbeStatusCard.test.tsx@@ -56,4 +56,41 @@ describe('AvailabilityProbeStatusCard', () => {expect(screen.getByText('Resource link is unresolved')).toBeInTheDocument();expect(screen.queryByText('Responding normally')).not.toBeInTheDocument();});++ it('shows certificate trust, expiry, hostname, issuer, and fingerprint', () => {+ render(() => (+ <AvailabilityProbeStatusCard+ availability={{+ targetId: 'probe-pulse',+ address: 'pulse.example.test',+ protocol: 'https',+ enabled: true,+ available: true,+ lastChecked: new Date().toISOString(),+ certificateExpiryWarningDays: 30,+ certificate: {+ subject: 'pulse.example.test',+ issuer: 'Example CA',+ dnsNames: ['pulse.example.test'],+ notBefore: '2026-01-01T00:00:00Z',+ notAfter: '2027-01-01T00:00:00Z',+ fingerprintSha256: '0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef',+ chainValid: true,+ hostnameValid: true,+ selfSigned: false,+ trustStatus: 'trusted',+ observedAt: '2026-08-06T12:00:00Z',+ },+ }}+ />+ ));++ expect(screen.getByText('Trusted')).toBeInTheDocument();+ expect(screen.getAllByText('pulse.example.test')).toHaveLength(2);+ expect(screen.getByText('Example CA')).toBeInTheDocument();+ expect(screen.getByText('Matches')).toBeInTheDocument();+ expect(screen.getByText('SHA-256')).toBeInTheDocument();+ expect(screen.getByTitle(/0123456789abcdef/)).toHaveTextContent('0123456789abcdef…');+ expect(screen.getByTitle('Warning window: 30 days')).toHaveTextContent('2027');+ });});diff --git a/frontend-modern/src/types/resource.ts b/frontend-modern/src/types/resource.tsindex a3e90ec412..c749a470e5 100644--- a/frontend-modern/src/types/resource.ts+++ b/frontend-modern/src/types/resource.ts@@ -1466,6 +1466,9 @@ export interface ResourceAvailabilityMeta {failureThreshold?: number;pollIntervalSeconds?: number;timeoutMillis?: number;+ certificateMonitoring?: boolean;+ certificateExpiryWarningDays?: number;+ certificate?: ResourceCertificateObservation;/*** Host agent that produced the latest observation. Absent when the check ran* on the Pulse server itself.@@ -1478,6 +1481,25 @@ export interface ResourceAvailabilityMeta {evidence?: EvidenceEnvelope;}+export type ResourceCertificateTrustStatus =+ 'trusted' | 'self-signed' | 'untrusted' | 'expired' | 'not-yet-valid';++export interface ResourceCertificateObservation {+ subject?: string;+ issuer?: string;+ serialNumber?: string;+ dnsNames?: string[];+ observedAt: string;+ notBefore: string;+ notAfter: string;+ fingerprintSha256: string;+ trustStatus: ResourceCertificateTrustStatus;+ chainValid: boolean;+ hostnameValid: boolean;+ selfSigned: boolean;+ trustError?: string;+}+/*** The core unified Resource type.* This is what the frontend receives from WebSocket state.resources[].diff --git a/internal/alerts/unified_incidents.go b/internal/alerts/unified_incidents.goindex 823a251244..542e7ed263 100644--- a/internal/alerts/unified_incidents.go+++ b/internal/alerts/unified_incidents.go@@ -525,6 +525,9 @@ func unifiedIncidentInstance(resource unifiedresources.Resource) string {func unifiedIncidentAlertType(resource unifiedresources.Resource, incident unifiedresources.ResourceIncident) string {code := strings.ToLower(strings.TrimSpace(incident.Code))+ if strings.HasPrefix(code, "certificate_") {+ return "certificate"+ }switch resource.Type {case unifiedresources.ResourceTypePhysicalDisk:if strings.Contains(code, "wear") {diff --git a/internal/alerts/unified_incidents_test.go b/internal/alerts/unified_incidents_test.goindex 907c43e956..a94ad3addc 100644--- a/internal/alerts/unified_incidents_test.go+++ b/internal/alerts/unified_incidents_test.go@@ -404,6 +404,14 @@ func TestSyncUnifiedResourceIncidentsSupportsVMwareVMs(t *testing.T) {}}+func TestUnifiedIncidentAlertTypeClassifiesCertificateIncidents(t *testing.T) {+ resource := unifiedresources.Resource{Type: unifiedresources.ResourceTypeNetworkEndpoint}+ incident := unifiedresources.ResourceIncident{Code: "certificate_expiring"}+ if got := unifiedIncidentAlertType(resource, incident); got != "certificate" {+ t.Fatalf("alert type = %q, want certificate", got)+ }+}+func TestSyncUnifiedResourceIncidentsMarksBackupTargetExposure(t *testing.T) {m := newTestManager(t)configureUnifiedEvalManager(t, m, unifiedEvalBaseConfig())diff --git a/internal/api/availability_handlers.go b/internal/api/availability_handlers.goindex 162db91b88..c1e4e1f61f 100644--- a/internal/api/availability_handlers.go+++ b/internal/api/availability_handlers.go@@ -10,6 +10,7 @@ import ("github.com/rcourtman/pulse-go-rewrite/internal/config""github.com/rcourtman/pulse-go-rewrite/internal/mock""github.com/rcourtman/pulse-go-rewrite/internal/monitoring"+ "github.com/rcourtman/pulse-go-rewrite/pkg/tlsutil")const availabilityTargetsPathPrefix = "/api/availability-targets/"@@ -26,10 +27,11 @@ type availabilityTargetResponse struct {}type availabilityTestResponse struct {- Success bool `json:"success"`- LatencyMillis int64 `json:"latencyMillis"`- Outcome string `json:"outcome,omitempty"`- Error string `json:"error,omitempty"`+ Success bool `json:"success"`+ LatencyMillis int64 `json:"latencyMillis"`+ Outcome string `json:"outcome,omitempty"`+ Error string `json:"error,omitempty"`+ Certificate *tlsutil.CertificateObservation `json:"certificate,omitempty"`}func NewAvailabilityHandlers(@@ -317,7 +319,7 @@ func (h *AvailabilityHandlers) testTarget(w http.ResponseWriter, r *http.Requestreturn}start := time.Now()- outcome, err := monitoring.ProbeAvailabilityTargetResult(r.Context(), target)+ result, err := monitoring.ProbeAvailabilityTargetDetailedResult(r.Context(), target)latencyMs := time.Since(start).Milliseconds()if err == nil && latencyMs == 0 {latencyMs = 1@@ -325,7 +327,8 @@ func (h *AvailabilityHandlers) testTarget(w http.ResponseWriter, r *http.Requestresponse := availabilityTestResponse{Success: err == nil,LatencyMillis: latencyMs,- Outcome: string(outcome),+ Outcome: string(result.Outcome),+ Certificate: result.Certificate.Clone(),}if err != nil {response.Error = err.Error()diff --git a/internal/api/availability_handlers_test.go b/internal/api/availability_handlers_test.goindex f014c0957f..b8c7157844 100644--- a/internal/api/availability_handlers_test.go+++ b/internal/api/availability_handlers_test.go@@ -140,7 +140,7 @@ func TestAvailabilityHandlersCreateNormalizesPingAlias(t *testing.T) {}func TestAvailabilityHandlersTestSavedTarget(t *testing.T) {- server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {+ server := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {w.WriteHeader(http.StatusNoContent)}))defer server.Close()@@ -150,7 +150,7 @@ func TestAvailabilityHandlersTestSavedTarget(t *testing.T) {ID: "status-page",Name: "Status page",Address: server.URL,- Protocol: config.AvailabilityProbeHTTP,+ Protocol: config.AvailabilityProbeHTTPS,Enabled: true,TimeoutMillis: 1000,})@@ -178,6 +178,9 @@ func TestAvailabilityHandlersTestSavedTarget(t *testing.T) {if !response.Success {t.Fatalf("response = %+v, want success", response)}+ if response.Certificate == nil || response.Certificate.TrustStatus != "self-signed" {+ t.Fatalf("certificate = %+v, want self-signed test-server certificate", response.Certificate)+ }}func TestAvailabilityHandlersListReturnsMockTargetsInMockMode(t *testing.T) {diff --git a/internal/availabilityprobe/probe.go b/internal/availabilityprobe/probe.goindex 0608536e95..36b8f87075 100644--- a/internal/availabilityprobe/probe.go+++ b/internal/availabilityprobe/probe.go@@ -39,6 +39,13 @@ const (OutcomeIndeterminate Outcome = "indeterminate")+// ProbeResult carries the reachability outcome plus HTTPS certificate posture+// when the target completed a TLS handshake.+type ProbeResult struct {+ Outcome Outcome `json:"outcome"`+ Certificate *tlsutil.CertificateObservation `json:"certificate,omitempty"`+}+// Run executes one agentless availability check.func Run(ctx context.Context, target config.AvailabilityTarget) error {_, err := Result(ctx, target)@@ -48,9 +55,16 @@ func Run(ctx context.Context, target config.AvailabilityTarget) error {// Result preserves UDP's open-or-filtered state rather than incorrectly// claiming that a silent UDP endpoint was proven reachable.func Result(ctx context.Context, target config.AvailabilityTarget) (Outcome, error) {+ result, err := DetailedResult(ctx, target)+ return result.Outcome, err+}++// DetailedResult preserves the legacy reachability result while publishing+// certificate posture for HTTPS checks through the same probe execution path.+func DetailedResult(ctx context.Context, target config.AvailabilityTarget) (ProbeResult, error) {target = config.NormalizeAvailabilityTarget(target)if err := target.Validate(); err != nil {- return OutcomeUnreachable, err+ return ProbeResult{Outcome: OutcomeUnreachable}, err}timeout := time.Duration(target.EffectiveTimeoutMillis()) * time.Millisecond@@ -62,15 +76,20 @@ func Result(ctx context.Context, target config.AvailabilityTarget) (Outcome, errswitch target.Protocol {case config.AvailabilityProbeICMP:- return outcomeFromError(probeICMP(probeCtx, target))+ outcome, err := outcomeFromError(probeICMP(probeCtx, target))+ return ProbeResult{Outcome: outcome}, errcase config.AvailabilityProbeTCP:- return outcomeFromError(probeTCP(probeCtx, target))+ outcome, err := outcomeFromError(probeTCP(probeCtx, target))+ return ProbeResult{Outcome: outcome}, errcase config.AvailabilityProbeUDP:- return probeUDP(probeCtx, target)+ outcome, err := probeUDP(probeCtx, target)+ return ProbeResult{Outcome: outcome}, errcase config.AvailabilityProbeHTTP, config.AvailabilityProbeHTTPS:- return outcomeFromError(probeHTTP(probeCtx, target, timeout))+ certificate, err := probeHTTP(probeCtx, target, timeout)+ outcome, probeErr := outcomeFromError(err)+ return ProbeResult{Outcome: outcome, Certificate: certificate}, probeErrdefault:- return OutcomeUnreachable, fmt.Errorf("unsupported availability protocol %q", target.Protocol)+ return ProbeResult{Outcome: OutcomeUnreachable}, fmt.Errorf("unsupported availability protocol %q", target.Protocol)}}@@ -243,38 +262,39 @@ func probeTCPViaSystem(ctx context.Context, host string, port, timeoutMillis intreturn fmt.Errorf("tcp probe failed: %s", details)}-func probeHTTP(ctx context.Context, target config.AvailabilityTarget, timeout time.Duration) error {+func probeHTTP(ctx context.Context, target config.AvailabilityTarget, timeout time.Duration) (*tlsutil.CertificateObservation, error) {u, err := target.HTTPURL()if err != nil {- return err+ return nil, err}opts := httpOutboundOptions()u, err = securityutil.ValidateOutboundFetchURL(ctx, u.String(), opts)if err != nil {- return fmt.Errorf("http availability target URL validation failed: %w", err)+ return nil, fmt.Errorf("http availability target URL validation failed: %w", err)}client := securityutil.NewRestrictedOutboundHTTPClient(timeout, opts)req, err := http.NewRequestWithContext(ctx, http.MethodHead, u.String(), nil)if err != nil {- return fmt.Errorf("build http availability request: %w", err)+ return nil, fmt.Errorf("build http availability request: %w", err)}req.Header.Set("User-Agent", "Pulse availability probe")resp, err := client.Do(req)if err == nil {defer resp.Body.Close()+ certificate := certificateObservationFromResponse(resp)if resp.StatusCode == http.StatusMethodNotAllowed {return probeHTTPGet(ctx, client, u)}if resp.StatusCode >= http.StatusInternalServerError {- return fmt.Errorf("http probe returned %s", resp.Status)+ return certificate, fmt.Errorf("http probe returned %s", resp.Status)}- return nil+ return certificate, nil}if ctxErr := ctx.Err(); ctxErr != nil {- return ctxErr+ return nil, ctxErr}- return fmt.Errorf("http probe failed: %w", err)+ return nil, fmt.Errorf("http probe failed: %w", err)}func httpOutboundOptions() securityutil.RestrictedOutboundHTTPOptions {@@ -286,22 +306,34 @@ func httpOutboundOptions() securityutil.RestrictedOutboundHTTPOptions {}}-func probeHTTPGet(ctx context.Context, client *http.Client, u *url.URL) error {+func probeHTTPGet(ctx context.Context, client *http.Client, u *url.URL) (*tlsutil.CertificateObservation, error) {req, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil)if err != nil {- return fmt.Errorf("build http availability fallback request: %w", err)+ return nil, fmt.Errorf("build http availability fallback request: %w", err)}req.Header.Set("User-Agent", "Pulse availability probe")resp, err := client.Do(req)if err != nil {if ctxErr := ctx.Err(); ctxErr != nil {- return ctxErr+ return nil, ctxErr}- return fmt.Errorf("http probe failed: %w", err)+ return nil, fmt.Errorf("http probe failed: %w", err)}defer resp.Body.Close()+ certificate := certificateObservationFromResponse(resp)if resp.StatusCode >= http.StatusInternalServerError {- return fmt.Errorf("http probe returned %s", resp.Status)+ return certificate, fmt.Errorf("http probe returned %s", resp.Status)+ }+ return certificate, nil+}++func certificateObservationFromResponse(response *http.Response) *tlsutil.CertificateObservation {+ if response == nil || response.TLS == nil {+ return nil+ }+ serverName := ""+ if response.Request != nil && response.Request.URL != nil {+ serverName = response.Request.URL.Hostname()}- return nil+ return tlsutil.ObservePeerCertificate(response.TLS, serverName, time.Now().UTC())}diff --git a/internal/availabilityprobe/probe_test.go b/internal/availabilityprobe/probe_test.goindex e405e2d0be..005d3aae50 100644--- a/internal/availabilityprobe/probe_test.go+++ b/internal/availabilityprobe/probe_test.go@@ -1,6 +1,14 @@package availabilityprobe-import "testing"+import (+ "context"+ "net/http"+ "net/http/httptest"+ "testing"++ "github.com/rcourtman/pulse-go-rewrite/internal/config"+ "github.com/rcourtman/pulse-go-rewrite/pkg/tlsutil"+)// Moved verbatim from internal/monitoring/availability_poller_test.go when the// probe execution core was extracted into this package.@@ -13,3 +21,32 @@ func TestAvailabilityHTTPOutboundOptionsUsesSharedPeerCertificateCapture(t *testt.Fatal("availability TLS config must reject missing or malformed peer certificates")}}++func TestDetailedResultCapturesHTTPSCertificatePosture(t *testing.T) {+ server := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {+ w.WriteHeader(http.StatusNoContent)+ }))+ defer server.Close()++ result, err := DetailedResult(context.Background(), config.AvailabilityTarget{+ Address: server.URL,+ Protocol: config.AvailabilityProbeHTTPS,+ Enabled: true,+ TimeoutMillis: 1000,+ })+ if err != nil {+ t.Fatalf("DetailedResult() error = %v", err)+ }+ if result.Outcome != OutcomeReachable {+ t.Fatalf("outcome = %q, want reachable", result.Outcome)+ }+ if result.Certificate == nil {+ t.Fatal("certificate observation = nil")+ }+ if result.Certificate.TrustStatus != tlsutil.CertificateTrustSelfSigned {+ t.Fatalf("trust status = %q, want self-signed", result.Certificate.TrustStatus)+ }+ if !result.Certificate.HostnameValid || result.Certificate.FingerprintSHA256 == "" {+ t.Fatalf("certificate projection = %+v", result.Certificate)+ }+}diff --git a/internal/config/availability.go b/internal/config/availability.goindex 42b0655577..16bc206b5c 100644--- a/internal/config/availability.go+++ b/internal/config/availability.go@@ -13,6 +13,7 @@ const (DefaultAvailabilityPollIntervalSecs = 60DefaultAvailabilityTimeoutMillis = 2000DefaultAvailabilityFailureThreshold = 2+ DefaultCertificateExpiryWarningDays = 30)type AvailabilityProbeProtocol string@@ -64,6 +65,11 @@ type AvailabilityTarget struct {TimeoutMillis int `json:"timeoutMillis,omitempty"`FailureThreshold int `json:"failureThreshold,omitempty"`LinkedResourceID string `json:"linkedResourceId,omitempty"`+ // CertificateMonitoringDisabled is an explicit opt-out. HTTPS targets+ // monitor certificate validity by default so existing saved targets gain+ // the 30-day warning without a migration rewrite.+ CertificateMonitoringDisabled bool `json:"certificateMonitoringDisabled,omitempty"`+ CertificateExpiryWarningDays int `json:"certificateExpiryWarningDays,omitempty"`// ProbeAgentID assigns execution to a remote host agent. Empty means the// check runs from the local Pulse instance. Agent existence is validated at// the API layer, not here, because config has no view of monitor state.@@ -136,6 +142,17 @@ func (t AvailabilityTarget) EffectiveFailureThreshold() int {return DefaultAvailabilityFailureThreshold}+func (t AvailabilityTarget) CertificateMonitoringEnabled() bool {+ return normalizeAvailabilityProbeProtocol(t.Protocol) == AvailabilityProbeHTTPS && !t.CertificateMonitoringDisabled+}++func (t AvailabilityTarget) EffectiveCertificateExpiryWarningDays() int {+ if t.CertificateExpiryWarningDays > 0 {+ return t.CertificateExpiryWarningDays+ }+ return DefaultCertificateExpiryWarningDays+}+func (t AvailabilityTarget) DisplayName() string {if name := strings.TrimSpace(t.Name); name != "" {return name@@ -192,6 +209,12 @@ func (t AvailabilityTarget) Validate() error {} else if t.UDPMode != "" || t.UDPRequest != "" || t.UDPExpected != "" {return fmt.Errorf("UDP settings may only be used with UDP availability targets")}+ if protocol != AvailabilityProbeHTTPS && (t.CertificateMonitoringDisabled || t.CertificateExpiryWarningDays != 0) {+ return fmt.Errorf("certificate monitoring settings may only be used with HTTPS availability targets")+ }+ if t.CertificateExpiryWarningDays < 0 || t.CertificateExpiryWarningDays > 3650 {+ return fmt.Errorf("certificate expiry warning must be between 0 and 3650 days")+ }if t.PollIntervalSecs > 0 && t.PollIntervalSecs < 10 {return fmt.Errorf("availability poll interval must be at least 10 seconds")}diff --git a/internal/config/availability_test.go b/internal/config/availability_test.goindex ed8ce09a15..5f688c3777 100644--- a/internal/config/availability_test.go+++ b/internal/config/availability_test.go@@ -231,3 +231,38 @@ func TestAvailabilityTargetProbeAgentIDRoundTripsThroughPersistence(t *testing.Tt.Fatalf("local target ProbeAgentID = %q, want empty", got)}}++func TestAvailabilityTargetCertificateMonitoringDefaultsAndValidation(t *testing.T) {+ httpsTarget := AvailabilityTarget{+ Address: "https://pulse.example.test",+ Protocol: AvailabilityProbeHTTPS,+ Enabled: true,+ }+ if !httpsTarget.CertificateMonitoringEnabled() {+ t.Fatal("HTTPS certificate monitoring should be enabled by default")+ }+ if got := httpsTarget.EffectiveCertificateExpiryWarningDays(); got != DefaultCertificateExpiryWarningDays {+ t.Fatalf("warning days = %d, want %d", got, DefaultCertificateExpiryWarningDays)+ }++ httpsTarget.CertificateMonitoringDisabled = true+ if httpsTarget.CertificateMonitoringEnabled() {+ t.Fatal("explicit certificate monitoring opt-out was ignored")+ }++ httpTarget := AvailabilityTarget{+ Address: "http://pulse.example.test",+ Protocol: AvailabilityProbeHTTP,+ Enabled: true,+ CertificateExpiryWarningDays: 14,+ }+ if err := httpTarget.Validate(); err == nil {+ t.Fatal("non-HTTPS target accepted certificate monitoring settings")+ }++ httpsTarget.CertificateMonitoringDisabled = false+ httpsTarget.CertificateExpiryWarningDays = 3651+ if err := httpsTarget.Validate(); err == nil {+ t.Fatal("HTTPS target accepted an excessive certificate warning window")+ }+}diff --git a/internal/hostagent/availability.go b/internal/hostagent/availability.goindex 4b12e0dab8..dfbc322307 100644--- a/internal/hostagent/availability.go+++ b/internal/hostagent/availability.go@@ -60,9 +60,10 @@ type pendingAvailabilityResult struct {// this agent and queues their results for the next host report. It owns its// scheduling entirely: the server sends assignments, never a schedule.type availabilityProbeModule struct {- logger zerolog.Logger- now func() time.Time- probe func(context.Context, config.AvailabilityTarget) (availabilityprobe.Outcome, error)+ logger zerolog.Logger+ now func() time.Time+ probe func(context.Context, config.AvailabilityTarget) (availabilityprobe.Outcome, error)+ detailedProbe func(context.Context, config.AvailabilityTarget) (availabilityprobe.ProbeResult, error)mu sync.Mutextargets []config.AvailabilityTarget@@ -77,11 +78,11 @@ type availabilityProbeModule struct {func newAvailabilityProbeModule(logger zerolog.Logger, targets []config.AvailabilityTarget) *availabilityProbeModule {module := &availabilityProbeModule{- logger: logger.With().Str("module", availabilityModuleName).Logger(),- now: time.Now,- probe: availabilityprobe.Result,- pending: utils.New[pendingAvailabilityResult](availabilityPendingCapacity),- reload: make(chan struct{}, 1),+ logger: logger.With().Str("module", availabilityModuleName).Logger(),+ now: time.Now,+ detailedProbe: availabilityprobe.DetailedResult,+ pending: utils.New[pendingAvailabilityResult](availabilityPendingCapacity),+ reload: make(chan struct{}, 1),}module.applyTargets(targets)return module@@ -227,7 +228,7 @@ func (m *availabilityProbeModule) check(ctx context.Context, target config.Availtimeout := time.Duration(target.EffectiveTimeoutMillis()) * time.MillisecondprobeCtx, cancel := context.WithTimeout(ctx, timeout)start := m.now()- outcome, err := m.probe(probeCtx, target)+ probeResult, err := m.runProbe(probeCtx, target)latency := m.now().Sub(start)cancel()@@ -242,9 +243,10 @@ func (m *availabilityProbeModule) check(ctx context.Context, target config.Availresult := agentshost.AvailabilityProbeResult{TargetID: target.ID,- Outcome: string(outcome),+ Outcome: string(probeResult.Outcome),LatencyMillis: latency.Milliseconds(),CheckedAt: m.now().UTC(),+ Certificate: probeResult.Certificate.Clone(),}if err != nil {message := strings.TrimSpace(err.Error())@@ -263,6 +265,17 @@ func (m *availabilityProbeModule) check(ctx context.Context, target config.AvailMsg("Completed assigned availability check")}+func (m *availabilityProbeModule) runProbe(ctx context.Context, target config.AvailabilityTarget) (availabilityprobe.ProbeResult, error) {+ if m.probe != nil {+ outcome, err := m.probe(ctx, target)+ return availabilityprobe.ProbeResult{Outcome: outcome}, err+ }+ if m.detailedProbe != nil {+ return m.detailedProbe(ctx, target)+ }+ return availabilityprobe.DetailedResult(ctx, target)+}+// enqueue queues one completed observation for the next report. The queue is// bounded and drops the oldest entry when full, so a long outage costs the// earliest observations rather than unbounded memory.diff --git a/internal/mock/availability_fixtures.go b/internal/mock/availability_fixtures.goindex 7c6872a98e..eb65d8bdc7 100644--- a/internal/mock/availability_fixtures.go+++ b/internal/mock/availability_fixtures.go@@ -10,12 +10,14 @@ import ("github.com/rcourtman/pulse-go-rewrite/internal/operationaltrust""github.com/rcourtman/pulse-go-rewrite/internal/storagehealth""github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources"+ "github.com/rcourtman/pulse-go-rewrite/pkg/tlsutil")const (- mockAvailabilityProbeICMP = "icmp"- mockAvailabilityProbeTCP = "tcp"- mockAvailabilityProbeHTTP = "http"+ mockAvailabilityProbeICMP = "icmp"+ mockAvailabilityProbeTCP = "tcp"+ mockAvailabilityProbeHTTP = "http"+ mockAvailabilityProbeHTTPS = "https"mockAvailabilityTargetMachine = "machine"mockAvailabilityTargetService = "service"@@ -75,7 +77,7 @@ func normalizeAvailabilityTargetFixture(target AvailabilityTargetFixture) Availaif target.Protocol == "" {target.Protocol = mockAvailabilityProbeICMP}- if target.Protocol == mockAvailabilityProbeHTTP {+ if target.Protocol == mockAvailabilityProbeHTTP || target.Protocol == mockAvailabilityProbeHTTPS {target.Address = strings.TrimSpace(target.Address)} else {target.Address = normalizeAvailabilityFixtureAddress(target.Address)@@ -151,7 +153,7 @@ func defaultAvailabilityFixtures(now time.Time) []AvailabilityFixture {TargetKind: mockAvailabilityTargetService,LinkedResourceID: "mock-swarm-cluster-1:service:svc-frontend-0",Address: "https://frontend.demo.pulse.local",- Protocol: mockAvailabilityProbeHTTP,+ Protocol: mockAvailabilityProbeHTTPS,Path: "/health",Enabled: true,PollIntervalSecs: 30,@@ -348,6 +350,22 @@ func availabilityFixtureRecord(fixture AvailabilityFixture, now time.Time) (unifTimeoutMillis: target.effectiveTimeoutMillis(),}data.Evidence = mockAvailabilityEvidence(target, fixture, lastSeen, now)+ if target.Protocol == mockAvailabilityProbeHTTPS {+ data.CertificateMonitoring = true+ data.CertificateExpiryWarningDays = 30+ data.Certificate = &tlsutil.CertificateObservation{+ Subject: "frontend.demo.pulse.local",+ Issuer: "Pulse Demo CA",+ DNSNames: []string{"frontend.demo.pulse.local"},+ ObservedAt: lastSeen,+ NotBefore: lastSeen.Add(-90 * 24 * time.Hour),+ NotAfter: lastSeen.Add(84 * 24 * time.Hour),+ FingerprintSHA256: "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",+ TrustStatus: tlsutil.CertificateTrustTrusted,+ ChainValid: true,+ HostnameValid: true,+ }+ }resource := unifiedresources.Resource{Type: unifiedresources.ResourceTypeNetworkEndpoint,Technology: string(target.Protocol),@@ -488,7 +506,7 @@ func availabilityFixtureTags(target AvailabilityTargetFixture) []string {tags = append(tags, target.TargetKind)}switch target.Protocol {- case mockAvailabilityProbeHTTP:+ case mockAvailabilityProbeHTTP, mockAvailabilityProbeHTTPS:tags = append(tags, "web-interface")case mockAvailabilityProbeTCP:if target.Port == 1883 {diff --git a/internal/mock/branchcov0723pm_test.go b/internal/mock/branchcov0723pm_test.goindex 1be3e517c2..9ed037a7c6 100644--- a/internal/mock/branchcov0723pm_test.go+++ b/internal/mock/branchcov0723pm_test.go@@ -77,7 +77,7 @@ func TestBranchcov0723pm_AvailabilityFixtures(t *testing.T) {seenIDs := make(map[string]int, len(fixtures))sawAvailable, sawUnavailable := false, falsevalidKinds := map[string]bool{"machine": true, "service": true, "device": true}- validProtocols := map[string]bool{"icmp": true, "tcp": true, "http": true}+ validProtocols := map[string]bool{"icmp": true, "tcp": true, "http": true, "https": true}for i, f := range fixtures {target := f.Target@@ -126,8 +126,8 @@ func TestBranchcov0723pm_AvailabilityFixtures(t *testing.T) {}// Documented protocol/field relationships.- if target.Protocol == "http" && strings.TrimSpace(target.Path) == "" {- t.Fatalf("fixture[%d] %q: http probe must carry a Path", i, target.ID)+ if (target.Protocol == "http" || target.Protocol == "https") && strings.TrimSpace(target.Path) == "" {+ t.Fatalf("fixture[%d] %q: HTTP probe must carry a Path", i, target.ID)}if target.Protocol == "tcp" && target.Port <= 0 {t.Fatalf("fixture[%d] %q: tcp probe must carry a Port > 0", i, target.ID)diff --git a/internal/mock/platform_fixtures_test.go b/internal/mock/platform_fixtures_test.goindex 59dd811470..98bc397835 100644--- a/internal/mock/platform_fixtures_test.go+++ b/internal/mock/platform_fixtures_test.go@@ -308,7 +308,7 @@ func TestFixtureGraphAttachesServiceAvailabilityFixturesToServiceResources(t *tet.Fatalf("Docker service metadata = %+v, want service id svc-frontend-0", dockerService.Docker)}if dockerService.Availability.TargetKind != "service" ||- dockerService.Availability.Protocol != "http" ||+ dockerService.Availability.Protocol != "https" ||dockerService.Availability.Path != "/health" ||dockerService.Availability.LatencyMillis != 9 {t.Fatalf("unexpected Docker service availability facet: %+v", dockerService.Availability)@@ -316,6 +316,11 @@ func TestFixtureGraphAttachesServiceAvailabilityFixturesToServiceResources(t *teif !slices.Contains(dockerService.Sources, unifiedresources.SourceAvailability) {t.Fatalf("expected Docker service sources to include availability, got %+v", dockerService.Sources)}+ if dockerService.Availability.Certificate == nil ||+ dockerService.Availability.Certificate.TrustStatus != "trusted" ||+ dockerService.Availability.CertificateExpiryWarningDays != 30 {+ t.Fatalf("Docker service certificate posture = %+v", dockerService.Availability)+ }if dockerService.Availability.CorrelationState != unifiedresources.AvailabilityCorrelationAttached ||dockerService.Availability.Evidence == nil ||dockerService.Availability.Evidence.Subject.ResourceID != dockerService.ID {diff --git a/internal/monitoring/availability_poller.go b/internal/monitoring/availability_poller.goindex 0d906ca873..311381e6bc 100644--- a/internal/monitoring/availability_poller.go+++ b/internal/monitoring/availability_poller.go@@ -3,6 +3,7 @@ package monitoringimport ("context""fmt"+ "math""net""sort""strings"@@ -13,8 +14,11 @@ import ("github.com/rcourtman/pulse-go-rewrite/internal/operationaltrust""github.com/rcourtman/pulse-go-rewrite/internal/storagehealth""github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources"+ "github.com/rcourtman/pulse-go-rewrite/pkg/tlsutil")+type tlsCert = tlsutil.CertificateObservation+// AvailabilityProbeStatus captures the last observed state of an agentless// endpoint probe.type AvailabilityProbeStatus struct {@@ -33,6 +37,8 @@ type AvailabilityProbeStatus struct {LastError string `json:"lastError,omitempty"`FailureThreshold int `json:"failureThreshold,omitempty"`ProbeAgentID string `json:"probeAgentId,omitempty"`+ Certificate *tlsCert `json:"certificate,omitempty"`+ CertificateCurrent bool `json:"-"`// ProbeReportReceivedAt is server-authored freshness evidence for a remote// observation. Keep it off the wire: LastChecked remains the agent's// observation time, while disconnect detection must not trust agent clock@@ -320,10 +326,10 @@ func (m *Monitor) RefreshAvailabilityTargets() {func (m *Monitor) pollAvailabilityTarget(ctx context.Context, target config.AvailabilityTarget) {target = config.NormalizeAvailabilityTarget(target)start := time.Now()- outcome, err := ProbeAvailabilityTargetResult(ctx, target)+ result, err := ProbeAvailabilityTargetDetailedResult(ctx, target)latency := time.Since(start)checkedAt := time.Now().UTC()- m.applyAvailabilityObservation(target, checkedAt, latency, outcome, err, "", time.Time{})+ m.applyAvailabilityObservation(target, checkedAt, latency, result.Outcome, err, result.Certificate, "", time.Time{})m.updateResourceStore(m.GetState())}@@ -336,10 +342,11 @@ func (m *Monitor) applyAvailabilityObservation(latency time.Duration,outcome AvailabilityProbeOutcome,probeErr error,+ certificate *tlsutil.CertificateObservation,probeAgentID string,probeReportReceivedAt time.Time,) {- m.setAvailabilityStatus(target, checkedAt, latency, outcome, probeErr, probeAgentID, probeReportReceivedAt)+ m.setAvailabilityStatusWithCertificate(target, checkedAt, latency, outcome, probeErr, certificate, probeAgentID, probeReportReceivedAt)if probeErr == nil {if m.stalenessTracker != nil {@@ -363,6 +370,19 @@ func (m *Monitor) setAvailabilityStatus(probeErr error,probeAgentID string,probeReportReceivedAt time.Time,+) {+ m.setAvailabilityStatusWithCertificate(target, checkedAt, latency, outcome, probeErr, nil, probeAgentID, probeReportReceivedAt)+}++func (m *Monitor) setAvailabilityStatusWithCertificate(+ target config.AvailabilityTarget,+ checkedAt time.Time,+ latency time.Duration,+ outcome AvailabilityProbeOutcome,+ probeErr error,+ certificate *tlsutil.CertificateObservation,+ probeAgentID string,+ probeReportReceivedAt time.Time,) {if m == nil {return@@ -370,6 +390,8 @@ func (m *Monitor) setAvailabilityStatus(status := availabilityStatusFromTarget(target)status.Outcome = string(outcome)status.LastChecked = checkedAt+ status.Certificate = certificate.Clone()+ status.CertificateCurrent = status.Certificate != nilstatus.ProbeAgentID = strings.TrimSpace(probeAgentID)if status.ProbeAgentID != "" {status.ProbeReportReceivedAt = probeReportReceivedAt.UTC()@@ -398,6 +420,9 @@ func (m *Monitor) setAvailabilityStatus(}if previous, ok := m.availabilityStatuses[target.ID]; ok {status.LastSuccess = previous.LastSuccess+ if status.Certificate == nil {+ status.Certificate = previous.Certificate.Clone()+ }if probeErr == nil {status.ConsecutiveFailures = 0status.LastError = ""@@ -428,6 +453,12 @@ func ProbeAvailabilityTargetResult(ctx context.Context, target config.Availabilireturn availabilityprobe.Result(ctx, target)}+// ProbeAvailabilityTargetDetailedResult adds HTTPS certificate posture while+// preserving the shared reachability vocabulary.+func ProbeAvailabilityTargetDetailedResult(ctx context.Context, target config.AvailabilityTarget) (availabilityprobe.ProbeResult, error) {+ return availabilityprobe.DetailedResult(ctx, target)+}+func availabilityStatusFromTarget(target config.AvailabilityTarget) AvailabilityProbeStatus {return AvailabilityProbeStatus{TargetID: target.ID,@@ -469,6 +500,9 @@ func availabilityResourceFromTarget(target config.AvailabilityTarget, status AvaPollIntervalSeconds: target.EffectivePollIntervalSecs(),TimeoutMillis: target.EffectiveTimeoutMillis(),}+ data.CertificateMonitoring = target.CertificateMonitoringEnabled()+ data.CertificateExpiryWarningDays = target.EffectiveCertificateExpiryWarningDays()+ data.Certificate = status.Certificate.Clone()observedAt := status.LastCheckedif observedAt.IsZero() {observedAt = lastSeen@@ -494,8 +528,9 @@ func availabilityResourceFromTarget(target config.AvailabilityTarget, status AvaAvailability: data,}if incident := availabilityIncident(target, status, lastSeen); incident != nil {- resource.Incidents = []unifiedresources.ResourceIncident{*incident}+ resource.Incidents = append(resource.Incidents, *incident)}+ resource.Incidents = append(resource.Incidents, availabilityCertificateIncidents(target, status)...)identity := unifiedresources.ResourceIdentity{}if ip := net.ParseIP(target.ProbeAddress()); ip != nil {@@ -637,6 +672,74 @@ func availabilityIncident(target config.AvailabilityTarget, status AvailabilityP}}+func availabilityCertificateIncidents(target config.AvailabilityTarget, status AvailabilityProbeStatus) []unifiedresources.ResourceIncident {+ certificate := status.Certificate+ if !target.Enabled || !target.CertificateMonitoringEnabled() || certificate == nil {+ return nil+ }+ // A retained observation remains useful in the UI during a later endpoint+ // outage, but it must not keep authoring current certificate incidents.+ if !status.CertificateCurrent || certificate.ObservedAt.IsZero() {+ return nil+ }+ observedAt := status.FreshnessTime()+ if observedAt.IsZero() {+ observedAt = certificate.ObservedAt+ }+ startedAt := observedAt+ base := target.DisplayName()+ incident := func(code string, severity storagehealth.RiskLevel, summary string) unifiedresources.ResourceIncident {+ return unifiedresources.ResourceIncident{+ Provider: string(unifiedresources.SourceAvailability),+ NativeID: target.ID,+ Code: code,+ Severity: severity,+ Source: string(unifiedresources.SourceAvailability),+ Summary: summary,+ StartedAt: startedAt,+ }+ }++ switch certificate.TrustStatus {+ case tlsutil.CertificateTrustExpired:+ return []unifiedresources.ResourceIncident{incident(+ "certificate_expired",+ storagehealth.RiskCritical,+ fmt.Sprintf("%s certificate expired on %s", base, certificate.NotAfter.Format("2 Jan 2006")),+ )}+ case tlsutil.CertificateTrustNotYetValid:+ return []unifiedresources.ResourceIncident{incident(+ "certificate_not_yet_valid",+ storagehealth.RiskCritical,+ fmt.Sprintf("%s certificate is not valid until %s", base, certificate.NotBefore.Format("2 Jan 2006")),+ )}+ case tlsutil.CertificateTrustUntrusted:+ summary := fmt.Sprintf("%s certificate is not trusted", base)+ if detail := strings.TrimSpace(certificate.TrustError); detail != "" {+ summary += ": " + detail+ }+ return []unifiedresources.ResourceIncident{incident("certificate_untrusted", storagehealth.RiskCritical, summary)}+ }+ if certificate.NotAfter.IsZero() {+ return nil+ }++ warningWindow := time.Duration(target.EffectiveCertificateExpiryWarningDays()) * 24 * time.Hour+ remaining := certificate.NotAfter.Sub(observedAt)+ if remaining > warningWindow {+ return nil+ }+ days := int(math.Ceil(remaining.Hours() / 24))+ if days < 0 {+ days = 0+ }+ return []unifiedresources.ResourceIncident{incident(+ "certificate_expiring",+ storagehealth.RiskWarning,+ fmt.Sprintf("%s certificate expires in %d days on %s", base, days, certificate.NotAfter.Format("2 Jan 2006")),+ )}+}+func availabilityConnectionKey(targetID string) string {targetID = strings.TrimSpace(targetID)if targetID == "" {diff --git a/internal/monitoring/availability_poller_test.go b/internal/monitoring/availability_poller_test.goindex 6f2241c737..647bc466b0 100644--- a/internal/monitoring/availability_poller_test.go+++ b/internal/monitoring/availability_poller_test.go@@ -11,6 +11,7 @@ import ("github.com/rcourtman/pulse-go-rewrite/internal/config""github.com/rcourtman/pulse-go-rewrite/internal/operationaltrust""github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources"+ "github.com/rcourtman/pulse-go-rewrite/pkg/tlsutil")func TestProbeAvailabilityTargetHTTPFallsBackToGETWhenHeadNotAllowed(t *testing.T) {@@ -236,3 +237,82 @@ func TestAvailabilityResourceFromTargetPreservesProbeTimes(t *testing.T) {t.Fatalf("last success = %v, want %v", resource.Availability.LastSuccess, succeededAt)}}++func TestAvailabilityResourceProjectsCertificateAndDefaultExpiryIncident(t *testing.T) {+ checkedAt := time.Date(2026, 8, 6, 12, 0, 0, 0, time.UTC)+ target := config.NormalizeAvailabilityTarget(config.AvailabilityTarget{+ ID: "pulse-ui",+ Name: "Pulse UI",+ Address: "https://pulse.example.test",+ Protocol: config.AvailabilityProbeHTTPS,+ Enabled: true,+ })+ status := availabilityStatusFromTarget(target)+ status.Available = true+ status.LastChecked = checkedAt+ status.CertificateCurrent = true+ status.Certificate = &tlsutil.CertificateObservation{+ Subject: "pulse.example.test",+ Issuer: "Example CA",+ NotBefore: checkedAt.Add(-300 * 24 * time.Hour),+ NotAfter: checkedAt.Add(20 * 24 * time.Hour),+ ObservedAt: checkedAt,+ FingerprintSHA256: "abcdef",+ ChainValid: true,+ HostnameValid: true,+ TrustStatus: tlsutil.CertificateTrustTrusted,+ }++ resource, _ := availabilityResourceFromTarget(target, status, "org-a", checkedAt.Add(time.Second))+ if resource.Availability == nil || resource.Availability.Certificate == nil {+ t.Fatalf("availability certificate = %+v", resource.Availability)+ }+ if !resource.Availability.CertificateMonitoring || resource.Availability.CertificateExpiryWarningDays != 30 {+ t.Fatalf("certificate monitoring projection = %+v", resource.Availability)+ }+ if len(resource.Incidents) != 1 || resource.Incidents[0].Code != "certificate_expiring" {+ t.Fatalf("incidents = %+v, want certificate_expiring", resource.Incidents)+ }+ if resource.Incidents[0].Summary != "Pulse UI certificate expires in 20 days on 26 Aug 2026" {+ t.Fatalf("summary = %q", resource.Incidents[0].Summary)+ }++ resource.Availability.Certificate.DNSNames = append(resource.Availability.Certificate.DNSNames, "changed")+ if len(status.Certificate.DNSNames) != 0 {+ t.Fatal("resource projection shares certificate slices with status")+ }+}++func TestAvailabilityCertificateTrustIncidentsRespectSelfSignedExemptionAndOptOut(t *testing.T) {+ checkedAt := time.Date(2026, 8, 6, 12, 0, 0, 0, time.UTC)+ target := config.AvailabilityTarget{+ ID: "endpoint",+ Name: "Endpoint",+ Address: "https://endpoint.example.test",+ Protocol: config.AvailabilityProbeHTTPS,+ Enabled: true,+ }+ status := AvailabilityProbeStatus{+ CertificateCurrent: true,+ Certificate: &tlsutil.CertificateObservation{+ ObservedAt: checkedAt,+ NotAfter: checkedAt.Add(180 * 24 * time.Hour),+ TrustStatus: tlsutil.CertificateTrustSelfSigned,+ SelfSigned: true,+ },+ }+ if incidents := availabilityCertificateIncidents(target, status); len(incidents) != 0 {+ t.Fatalf("self-signed incidents = %+v, want none", incidents)+ }++ status.Certificate.TrustStatus = tlsutil.CertificateTrustUntrusted+ status.Certificate.SelfSigned = false+ if incidents := availabilityCertificateIncidents(target, status); len(incidents) != 1 || incidents[0].Code != "certificate_untrusted" {+ t.Fatalf("untrusted incidents = %+v", incidents)+ }++ target.CertificateMonitoringDisabled = true+ if incidents := availabilityCertificateIncidents(target, status); len(incidents) != 0 {+ t.Fatalf("disabled monitoring incidents = %+v, want none", incidents)+ }+}diff --git a/internal/monitoring/availability_probe_agent.go b/internal/monitoring/availability_probe_agent.goindex a7aa9bbd8d..3ba57993e5 100644--- a/internal/monitoring/availability_probe_agent.go+++ b/internal/monitoring/availability_probe_agent.go@@ -9,6 +9,7 @@ import ("github.com/rcourtman/pulse-go-rewrite/internal/config"agentshost "github.com/rcourtman/pulse-go-rewrite/pkg/agents/host"pkglicensing "github.com/rcourtman/pulse-go-rewrite/pkg/licensing"+ "github.com/rcourtman/pulse-go-rewrite/pkg/tlsutil""github.com/rs/zerolog/log")@@ -28,6 +29,7 @@ type ProbeAvailabilityResult struct {LatencyMillis int64CheckedAt time.TimeError string+ Certificate *tlsutil.CertificateObservation}// availabilityProbeAssignmentTracker provides a grace reference for a newly@@ -60,6 +62,7 @@ func probeAvailabilityResultsFromReport(reported []agentshost.AvailabilityProbeRLatencyMillis: entry.LatencyMillis,CheckedAt: entry.CheckedAt,Error: strings.TrimSpace(entry.Error),+ Certificate: entry.Certificate.Clone(),})}return results@@ -135,7 +138,7 @@ func (m *Monitor) applyProbeAvailabilityResultsAt(hostID string, results []Probelatency = 0}outcome, probeErr := probeResultOutcome(result)- m.applyAvailabilityObservation(target, checkedAt.UTC(), latency, outcome, probeErr, hostID, receivedAt)+ m.applyAvailabilityObservation(target, checkedAt.UTC(), latency, outcome, probeErr, result.Certificate, hostID, receivedAt)applied++}diff --git a/internal/monitoring/availability_probe_agent_test.go b/internal/monitoring/availability_probe_agent_test.goindex ff96a4264d..aef4f4aa19 100644--- a/internal/monitoring/availability_probe_agent_test.go+++ b/internal/monitoring/availability_probe_agent_test.go@@ -10,6 +10,7 @@ import ("github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources"agentshost "github.com/rcourtman/pulse-go-rewrite/pkg/agents/host"pkglicensing "github.com/rcourtman/pulse-go-rewrite/pkg/licensing"+ "github.com/rcourtman/pulse-go-rewrite/pkg/tlsutil")func newProbeAgentTestMonitor(t *testing.T, targets ...config.AvailabilityTarget) *Monitor {@@ -701,8 +702,9 @@ func TestProbeAvailabilityResultsFromReportNormalizesOutcomes(t *testing.T) {}checkedAt := time.Now().UTC()+ reportedCertificate := &tlsutil.CertificateObservation{Subject: "pulse.example.test", DNSNames: []string{"pulse.example.test"}}results := probeAvailabilityResultsFromReport([]agentshost.AvailabilityProbeResult{- {TargetID: " padded ", Outcome: " REACHABLE ", LatencyMillis: 4, CheckedAt: checkedAt},+ {TargetID: " padded ", Outcome: " REACHABLE ", LatencyMillis: 4, CheckedAt: checkedAt, Certificate: reportedCertificate},{TargetID: "b", Outcome: "unreachable", Error: " icmp probe timed out "},{TargetID: "c", Outcome: "who-knows"},{TargetID: "d", Outcome: ""},@@ -713,6 +715,13 @@ func TestProbeAvailabilityResultsFromReportNormalizesOutcomes(t *testing.T) {if results[0].TargetID != "padded" || results[0].Outcome != AvailabilityProbeReachable {t.Fatalf("first result = %+v", results[0])}+ if results[0].Certificate == nil || results[0].Certificate.Subject != "pulse.example.test" {+ t.Fatalf("first certificate = %+v", results[0].Certificate)+ }+ results[0].Certificate.DNSNames[0] = "changed.example.test"+ if reportedCertificate.DNSNames[0] != "pulse.example.test" {+ t.Fatal("wire certificate was not cloned")+ }if results[1].Error != "icmp probe timed out" || results[1].Outcome != AvailabilityProbeUnreachable {t.Fatalf("second result = %+v", results[1])}diff --git a/internal/unifiedresources/clone.go b/internal/unifiedresources/clone.goindex e3427d459d..4da5e55c3e 100644--- a/internal/unifiedresources/clone.go+++ b/internal/unifiedresources/clone.go@@ -400,6 +400,7 @@ func cloneAvailabilityData(in *AvailabilityData) *AvailabilityData {out := *inout.LastChecked = cloneTimePtr(in.LastChecked)out.LastSuccess = cloneTimePtr(in.LastSuccess)+ out.Certificate = in.Certificate.Clone()if in.Evidence != nil {evidence := in.Evidence.Clone()out.Evidence = &evidencediff --git a/internal/unifiedresources/clone_test.go b/internal/unifiedresources/clone_test.goindex 1a7c7a080b..2f5d35a03e 100644--- a/internal/unifiedresources/clone_test.go+++ b/internal/unifiedresources/clone_test.go@@ -6,6 +6,7 @@ import ("github.com/rcourtman/pulse-go-rewrite/internal/models""github.com/rcourtman/pulse-go-rewrite/internal/storagehealth"+ "github.com/rcourtman/pulse-go-rewrite/pkg/tlsutil")// --- cloneResource: top-level isolation ---@@ -202,6 +203,7 @@ func TestCloneResource_MutateAvailabilityTimes(t *testing.T) {Availability: &AvailabilityData{LastChecked: &checkedAt,LastSuccess: &succeededAt,+ Certificate: &tlsutil.CertificateObservation{DNSNames: []string{"pulse.example.test"}},},AvailabilityChecks: []AvailabilityData{{TargetID: "probe-1",@@ -213,6 +215,7 @@ func TestCloneResource_MutateAvailabilityTimes(t *testing.T) {*cloned.Availability.LastChecked = checkedAt.Add(time.Hour)*cloned.Availability.LastSuccess = succeededAt.Add(time.Hour)+ cloned.Availability.Certificate.DNSNames[0] = "changed.example.test"*cloned.AvailabilityChecks[0].LastChecked = checkedAt.Add(2 * time.Hour)if !original.Availability.LastChecked.Equal(checkedAt) {t.Error("mutating cloned availability LastChecked should not affect original")@@ -220,6 +223,9 @@ func TestCloneResource_MutateAvailabilityTimes(t *testing.T) {if !original.Availability.LastSuccess.Equal(succeededAt) {t.Error("mutating cloned availability LastSuccess should not affect original")}+ if original.Availability.Certificate.DNSNames[0] != "pulse.example.test" {+ t.Error("mutating cloned availability certificate should not affect original")+ }if !original.AvailabilityChecks[0].LastChecked.Equal(checkedAt) {t.Error("mutating cloned AvailabilityChecks should not affect original")}diff --git a/internal/unifiedresources/types.go b/internal/unifiedresources/types.goindex 89cda5ca7d..89085e0863 100644--- a/internal/unifiedresources/types.go+++ b/internal/unifiedresources/types.go@@ -8,6 +8,7 @@ import ("github.com/rcourtman/pulse-go-rewrite/internal/operationaltrust""github.com/rcourtman/pulse-go-rewrite/internal/storagehealth""github.com/rcourtman/pulse-go-rewrite/pkg/diskinventory"+ "github.com/rcourtman/pulse-go-rewrite/pkg/tlsutil")// Resource represents a unified resource aggregated across multiple data sources.@@ -1742,6 +1743,10 @@ type AvailabilityData struct {CorrelationReason string `json:"correlationReason,omitempty"`CorrelationCandidates int `json:"correlationCandidates,omitempty"`Evidence *operationaltrust.EvidenceEnvelope `json:"evidence,omitempty"`++ CertificateMonitoring bool `json:"certificateMonitoring,omitempty"`+ CertificateExpiryWarningDays int `json:"certificateExpiryWarningDays,omitempty"`+ Certificate *tlsutil.CertificateObservation `json:"certificate,omitempty"`}// K8sMetricCapabilities describes which Kubernetes metric families are availablediff --git a/pkg/agents/host/report.go b/pkg/agents/host/report.goindex 3f8443baa7..aa8cfda0fd 100644--- a/pkg/agents/host/report.go+++ b/pkg/agents/host/report.go@@ -7,6 +7,7 @@ import ("time""github.com/rcourtman/pulse-go-rewrite/pkg/diskinventory"+ "github.com/rcourtman/pulse-go-rewrite/pkg/tlsutil")const reportSequenceVersion = "v1"@@ -135,11 +136,12 @@ type ProxmoxLXCContainer struct {// ("reachable", "unreachable", "indeterminate"); anything else is treated as// indeterminate by the server.type AvailabilityProbeResult struct {- TargetID string `json:"targetId"`- Outcome string `json:"outcome"`- LatencyMillis int64 `json:"latencyMillis"`- CheckedAt time.Time `json:"checkedAt"`- Error string `json:"error,omitempty"`+ TargetID string `json:"targetId"`+ Outcome string `json:"outcome"`+ LatencyMillis int64 `json:"latencyMillis"`+ CheckedAt time.Time `json:"checkedAt"`+ Error string `json:"error,omitempty"`+ Certificate *tlsutil.CertificateObservation `json:"certificate,omitempty"`}// ClusterNodeSensors contains temperature sensor data collected from a Proxmoxdiff --git a/pkg/agents/host/report_test.go b/pkg/agents/host/report_test.goindex a97254618c..95fb6d7a2e 100644--- a/pkg/agents/host/report_test.go+++ b/pkg/agents/host/report_test.go@@ -4,6 +4,8 @@ import ("encoding/json""testing""time"++ "github.com/rcourtman/pulse-go-rewrite/pkg/tlsutil")func TestLegacyReportJSONDefaultsOperationReceiptProtocolUnsupported(t *testing.T) {@@ -589,7 +591,13 @@ func TestReportAvailabilityResultsJSONRoundTrip(t *testing.T) {Agent: AgentInfo{ID: "probe-agent"},Host: HostInfo{Hostname: "probe-agent.local"},AvailabilityResults: []AvailabilityProbeResult{- {TargetID: "target-1", Outcome: "reachable", LatencyMillis: 12, CheckedAt: checkedAt},+ {+ TargetID: "target-1", Outcome: "reachable", LatencyMillis: 12, CheckedAt: checkedAt,+ Certificate: &tlsutil.CertificateObservation{+ Subject: "pulse.example.test", TrustStatus: tlsutil.CertificateTrustTrusted,+ ObservedAt: checkedAt, DNSNames: []string{"pulse.example.test"},+ },+ },{TargetID: "target-2", Outcome: "unreachable", CheckedAt: checkedAt, Error: "icmp probe timed out"},},Timestamp: checkedAt,@@ -620,6 +628,9 @@ func TestReportAvailabilityResultsJSONRoundTrip(t *testing.T) {if !first.CheckedAt.Equal(checkedAt) {t.Fatalf("checkedAt = %v, want %v", first.CheckedAt, checkedAt)}+ if first.Certificate == nil || first.Certificate.TrustStatus != tlsutil.CertificateTrustTrusted || len(first.Certificate.DNSNames) != 1 {+ t.Fatalf("certificate = %+v", first.Certificate)+ }if decoded.AvailabilityResults[1].Error != "icmp probe timed out" {t.Fatalf("second result = %+v", decoded.AvailabilityResults[1])}diff --git a/pkg/tlsutil/certificate.go b/pkg/tlsutil/certificate.gonew file mode 100644index 0000000000..f05a259357--- /dev/null+++ b/pkg/tlsutil/certificate.go@@ -0,0 +1,165 @@+package tlsutil++import (+ "crypto/sha256"+ "crypto/tls"+ "crypto/x509"+ "encoding/hex"+ "errors"+ "net"+ "strings"+ "time"+)++// CertificateTrustStatus is the bounded trust result published for an HTTPS+// availability observation. It separates an intentionally self-signed leaf+// from an otherwise untrusted chain so operators can distinguish the two.+type CertificateTrustStatus string++const (+ CertificateTrustTrusted CertificateTrustStatus = "trusted"+ CertificateTrustSelfSigned CertificateTrustStatus = "self-signed"+ CertificateTrustUntrusted CertificateTrustStatus = "untrusted"+ CertificateTrustExpired CertificateTrustStatus = "expired"+ CertificateTrustNotYetValid CertificateTrustStatus = "not-yet-valid"+)++// CertificateObservation is the canonical, secret-free TLS leaf projection+// shared by local availability checks, remote probe-agent reports and unified+// resource consumers.+type CertificateObservation struct {+ Subject string `json:"subject,omitempty"`+ Issuer string `json:"issuer,omitempty"`+ SerialNumber string `json:"serialNumber,omitempty"`+ DNSNames []string `json:"dnsNames,omitempty"`+ ObservedAt time.Time `json:"observedAt"`+ NotBefore time.Time `json:"notBefore"`+ NotAfter time.Time `json:"notAfter"`+ FingerprintSHA256 string `json:"fingerprintSha256"`+ TrustStatus CertificateTrustStatus `json:"trustStatus"`+ ChainValid bool `json:"chainValid"`+ HostnameValid bool `json:"hostnameValid"`+ SelfSigned bool `json:"selfSigned"`+ TrustError string `json:"trustError,omitempty"`+}++// Clone returns an independent observation for registry and report snapshots.+func (o *CertificateObservation) Clone() *CertificateObservation {+ if o == nil {+ return nil+ }+ out := *o+ out.DNSNames = append([]string(nil), o.DNSNames...)+ return &out+}++// ObservePeerCertificate derives the leaf identity, validity and trust posture+// from a completed TLS connection. The caller may use an intentionally+// unverified transport for reachability, while this function performs the+// explicit trust and hostname checks reported to the operator.+func ObservePeerCertificate(state *tls.ConnectionState, serverName string, now time.Time) *CertificateObservation {+ if state == nil || len(state.PeerCertificates) == 0 {+ return nil+ }+ leaf := state.PeerCertificates[0]+ if leaf == nil {+ return nil+ }+ if now.IsZero() {+ now = time.Now().UTC()+ } else {+ now = now.UTC()+ }+ serverName = strings.TrimSpace(serverName)++ fingerprint := sha256.Sum256(leaf.Raw)+ observation := &CertificateObservation{+ Subject: certificateName(leaf.Subject.CommonName, leaf.Subject.String()),+ Issuer: certificateName(leaf.Issuer.CommonName, leaf.Issuer.String()),+ SerialNumber: strings.ToUpper(leaf.SerialNumber.Text(16)),+ DNSNames: append([]string(nil), leaf.DNSNames...),+ ObservedAt: now,+ NotBefore: leaf.NotBefore.UTC(),+ NotAfter: leaf.NotAfter.UTC(),+ FingerprintSHA256: hex.EncodeToString(fingerprint[:]),+ SelfSigned: certificateIsSelfSigned(leaf),+ }++ hostnameErr := verifyCertificateHostname(leaf, serverName)+ observation.HostnameValid = hostnameErr == nil+ chainErr := verifyCertificateChain(state.PeerCertificates, now)+ observation.ChainValid = chainErr == nil++ switch {+ case now.Before(leaf.NotBefore):+ observation.TrustStatus = CertificateTrustNotYetValid+ case now.After(leaf.NotAfter):+ observation.TrustStatus = CertificateTrustExpired+ case observation.SelfSigned:+ observation.TrustStatus = CertificateTrustSelfSigned+ case observation.ChainValid && observation.HostnameValid:+ observation.TrustStatus = CertificateTrustTrusted+ default:+ observation.TrustStatus = CertificateTrustUntrusted+ }+ observation.TrustError = certificateTrustError(chainErr, hostnameErr, observation.SelfSigned)+ return observation+}++func certificateName(commonName, distinguishedName string) string {+ if value := strings.TrimSpace(commonName); value != "" {+ return value+ }+ return strings.TrimSpace(distinguishedName)+}++func certificateIsSelfSigned(certificate *x509.Certificate) bool {+ if certificate == nil || certificate.RawSubject == nil || certificate.RawIssuer == nil {+ return false+ }+ if !strings.EqualFold(hex.EncodeToString(certificate.RawSubject), hex.EncodeToString(certificate.RawIssuer)) {+ return false+ }+ return certificate.CheckSignatureFrom(certificate) == nil+}++func verifyCertificateHostname(certificate *x509.Certificate, serverName string) error {+ if certificate == nil {+ return errors.New("certificate is missing")+ }+ if serverName == "" {+ return errors.New("target hostname is missing")+ }+ if ip := net.ParseIP(serverName); ip != nil {+ return certificate.VerifyHostname(ip.String())+ }+ return certificate.VerifyHostname(serverName)+}++func verifyCertificateChain(certificates []*x509.Certificate, now time.Time) error {+ if len(certificates) == 0 || certificates[0] == nil {+ return errors.New("certificate chain is missing")+ }+ intermediates := x509.NewCertPool()+ for _, certificate := range certificates[1:] {+ if certificate != nil {+ intermediates.AddCert(certificate)+ }+ }+ _, err := certificates[0].Verify(x509.VerifyOptions{+ Intermediates: intermediates,+ CurrentTime: now,+ })+ return err+}++func certificateTrustError(chainErr, hostnameErr error, selfSigned bool) string {+ parts := make([]string, 0, 2)+ if chainErr != nil && !selfSigned {+ parts = append(parts, "trust chain: "+chainErr.Error())+ }+ if hostnameErr != nil {+ parts = append(parts, "hostname: "+hostnameErr.Error())+ }+ return strings.Join(parts, ". ")+}diff --git a/pkg/tlsutil/certificate_test.go b/pkg/tlsutil/certificate_test.gonew file mode 100644index 0000000000..f5d19b3ccb--- /dev/null+++ b/pkg/tlsutil/certificate_test.go@@ -0,0 +1,89 @@+package tlsutil++import (+ "crypto/rand"+ "crypto/rsa"+ "crypto/tls"+ "crypto/x509"+ "crypto/x509/pkix"+ "math/big"+ "testing"+ "time"+)++func TestObservePeerCertificateClassifiesSelfSignedAndValidity(t *testing.T) {+ now := time.Date(2026, 8, 6, 12, 0, 0, 0, time.UTC)+ leaf := issueTestCertificate(t, pkix.Name{CommonName: "pulse.local"}, []string{"pulse.local"}, now.Add(-time.Hour), now.Add(30*24*time.Hour))+ state := &tls.ConnectionState{PeerCertificates: []*x509.Certificate{leaf}}++ observation := ObservePeerCertificate(state, "pulse.local", now)+ if observation == nil {+ t.Fatal("expected certificate observation")+ }+ if observation.TrustStatus != CertificateTrustSelfSigned || !observation.SelfSigned {+ t.Fatalf("trust = %q selfSigned=%v, want self-signed", observation.TrustStatus, observation.SelfSigned)+ }+ if !observation.HostnameValid {+ t.Fatalf("hostname should validate: %s", observation.TrustError)+ }+ if observation.NotAfter != leaf.NotAfter.UTC() || len(observation.FingerprintSHA256) != 64 {+ t.Fatalf("unexpected certificate projection: %+v", observation)+ }++ expired := issueTestCertificate(t, pkix.Name{CommonName: "pulse.local"}, []string{"pulse.local"}, now.Add(-48*time.Hour), now.Add(-time.Hour))+ expiredObservation := ObservePeerCertificate(&tls.ConnectionState{PeerCertificates: []*x509.Certificate{expired}}, "pulse.local", now)+ if expiredObservation == nil || expiredObservation.TrustStatus != CertificateTrustExpired {+ t.Fatalf("expired trust = %+v, want expired", expiredObservation)+ }+}++func TestObservePeerCertificateReportsHostnameMismatch(t *testing.T) {+ now := time.Date(2026, 8, 6, 12, 0, 0, 0, time.UTC)+ leaf := issueTestCertificate(t, pkix.Name{CommonName: "pulse.local"}, []string{"pulse.local"}, now.Add(-time.Hour), now.Add(30*24*time.Hour))++ observation := ObservePeerCertificate(&tls.ConnectionState{PeerCertificates: []*x509.Certificate{leaf}}, "other.local", now)+ if observation == nil || observation.HostnameValid {+ t.Fatalf("hostname result = %+v, want mismatch", observation)+ }+ if observation.TrustError == "" {+ t.Fatal("expected bounded hostname error")+ }+}++func TestCertificateObservationCloneOwnsDNSNames(t *testing.T) {+ original := &CertificateObservation{DNSNames: []string{"pulse.local"}}+ cloned := original.Clone()+ cloned.DNSNames[0] = "changed.local"+ if original.DNSNames[0] != "pulse.local" {+ t.Fatal("clone mutated original DNS names")+ }+}++func issueTestCertificate(t *testing.T, subject pkix.Name, dnsNames []string, notBefore, notAfter time.Time) *x509.Certificate {+ t.Helper()+ key, err := rsa.GenerateKey(rand.Reader, 2048)+ if err != nil {+ t.Fatal(err)+ }+ template := &x509.Certificate{+ SerialNumber: big.NewInt(1),+ Subject: subject,+ Issuer: subject,+ DNSNames: dnsNames,+ NotBefore: notBefore,+ NotAfter: notAfter,+ KeyUsage: x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign,+ ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth},+ BasicConstraintsValid: true,+ IsCA: true,+ }+ der, err := x509.CreateCertificate(rand.Reader, template, template, &key.PublicKey, key)+ if err != nil {+ t.Fatal(err)+ }+ certificate, err := x509.ParseCertificate(der)+ if err != nil {+ t.Fatal(err)+ }+ return certificate+}diff --git a/scripts/release_control/canonical_completion_guard_test.py b/scripts/release_control/canonical_completion_guard_test.pyindex 5466bc550f..b7d148cdb8 100644--- a/scripts/release_control/canonical_completion_guard_test.py+++ b/scripts/release_control/canonical_completion_guard_test.py@@ -249,6 +249,7 @@ class CanonicalCompletionGuardTest(unittest.TestCase):self.assertEqual(policy_ids,[+ "availability-certificate-runtime","discovery-provider-runtime","host-agent-ingest-runtime","truenas-runtime",@@ -442,6 +443,7 @@ class CanonicalCompletionGuardTest(unittest.TestCase):"internal/monitoring/monitor_host_agents_test.go","internal/monitoring/monitor_package_updates_test.go","internal/unifiedresources/code_standards_test.go",+ "pkg/agents/host/report_test.go",],}],@@ -1172,6 +1174,7 @@ class CanonicalCompletionGuardTest(unittest.TestCase):"internal/api/ai_handlers_more_test.go","internal/api/ai_handlers_patrol_actions_additional_test.go","internal/api/audit_handlers_test.go",+ "internal/api/availability_handlers_test.go","internal/api/contract_test.go","internal/api/docker_agents_report_size_test.go","internal/api/external_probe_notifications_test.go",diff --git a/scripts/release_control/subsystem_lookup_test.py b/scripts/release_control/subsystem_lookup_test.pyindex c6e3102053..c994e9e7e8 100644--- a/scripts/release_control/subsystem_lookup_test.py+++ b/scripts/release_control/subsystem_lookup_test.py@@ -4208,6 +4208,7 @@ class SubsystemLookupTest(unittest.TestCase):"internal/monitoring/monitor_host_agents_test.go","internal/monitoring/monitor_package_updates_test.go","internal/unifiedresources/code_standards_test.go",+ "pkg/agents/host/report_test.go",],)