Private/Get-SqlCertFileThumbprint.ps1

# =============================================================================
# Script : Private/Get-SqlCertFileThumbprint.ps1
# Author : Keith Ramsey
# Created : 2026-05-15
# =============================================================================
# Change Log
# -----------------------------------------------------------------------------
# 2026-05-15 Keith Ramsey Initial: read a thumbprint straight from a
# .cer/.pfx, store-independent (works even when
# the import target is a remote node). Migrated
# from the worker's Get-FileThumbprint.
# =============================================================================
# Decision Contract (see Docs/DECISION_REGISTER.md)
# -----------------------------------------------------------------------------
# Must : never throw; return $null on any read failure (honest absence,
# not a fabricated value). Underpins the node-independent
# thumbprint threading that fixed the worker's S1 wrong-cert bug.
# =============================================================================

function Get-SqlCertFileThumbprint {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory)] [string] $Path,
        [System.Security.SecureString] $Password
    )
    try {
        $x = if ($Password) {
            New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 $Path, $Password
        }
        else {
            New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 $Path
        }
        $x.Thumbprint
    }
    catch { $null }
}