Files
Backup/_NDGOV_WindowsTeam/ITD.Infra-Certificate-External.Sectigo/Public/Test-SectigoCertificateRequest.ps1
T
Zack Meier 1d304511b8 update
2026-04-15 15:45:50 -05:00

39 lines
954 B
PowerShell

function Test-SectigoCertificateRequest {
[CmdletBinding(SupportsShouldProcess=$true)]
param (
[string]$FilePath,
[string]$csr
)
if ($FilePath) {
[string]$csr = (Get-Content -Path $FilePath -Raw)
}
[string]$dcvUrl = "https://certificates.nd.gov/api/csr/validate/string"
$headers = @{
"accept" = "application/json"
"Content-Type" = "application/json" # <-- Cleaned up syntax
}
$Body = @{
"csr" = $csr
}
$jsonBody = $body | ConvertTo-Json
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
# --- API Call ---
Write-Verbose "Attempting to retrieve certificate for Order ID: $OrderId"
try {
$response = Invoke-RestMethod -Uri $dcvUrl -Method Post -Headers $headers -Body $jsonBody
$response
} catch {
Write-Error "API Request Failed: $($_.Exception.Message)"|convertfrom-json
return $null
}
}