Update vCenter-SSL.ps1
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env pwsh
|
#!/usr/bin/env pwsh
|
||||||
# -----------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------
|
||||||
# vCenter + Posh-ACME Script (Linux/macOS-safe, HttpClient login)
|
# vCenter + Posh-ACME Script (Linux/macOS-safe, TLS 1.2 enforced)
|
||||||
# -----------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------
|
||||||
|
|
||||||
. /opt/idssys/nodemgmt/conf/powerwall/settings.ps1
|
. /opt/idssys/nodemgmt/conf/powerwall/settings.ps1
|
||||||
@@ -11,6 +11,11 @@
|
|||||||
$global:helpme = $null
|
$global:helpme = $null
|
||||||
$global:responseBody = $null
|
$global:responseBody = $null
|
||||||
|
|
||||||
|
# ----------------------------
|
||||||
|
# Force TLS 1.2 globally
|
||||||
|
# ----------------------------
|
||||||
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||||
|
|
||||||
# ----------------------------
|
# ----------------------------
|
||||||
# Error handler
|
# Error handler
|
||||||
# ----------------------------
|
# ----------------------------
|
||||||
@@ -87,7 +92,7 @@ $EmailContact = $ACMEEMAIL
|
|||||||
|
|
||||||
[PSCredential]$Credential = New-Object System.Management.Automation.PSCredential -ArgumentList $VCENTERUSER, (ConvertTo-SecureString $VCENTERPASS -AsPlainText -Force)
|
[PSCredential]$Credential = New-Object System.Management.Automation.PSCredential -ArgumentList $VCENTERUSER, (ConvertTo-SecureString $VCENTERPASS -AsPlainText -Force)
|
||||||
|
|
||||||
# PowerDNS plugin args (plain string API key!)
|
# PowerDNS plugin args (plain string API key)
|
||||||
$pArgs = @{
|
$pArgs = @{
|
||||||
PowerDNSApiHost = $WDNSHOST
|
PowerDNSApiHost = $WDNSHOST
|
||||||
PowerDNSApiKey = $PDNSAPI
|
PowerDNSApiKey = $PDNSAPI
|
||||||
@@ -105,12 +110,13 @@ if (-not (Get-Module -ListAvailable -Name Posh-ACME)) {
|
|||||||
Import-Module Posh-ACME -ErrorAction Stop
|
Import-Module Posh-ACME -ErrorAction Stop
|
||||||
|
|
||||||
# ----------------------------
|
# ----------------------------
|
||||||
# Connect to vCenter API using HttpClient (robust)
|
# Connect to vCenter API using HttpClient (TLS 1.2 enforced)
|
||||||
# ----------------------------
|
# ----------------------------
|
||||||
Write-Host "Connecting to vCenter at $vCenterURL ..." -ForegroundColor Cyan
|
Write-Host "Connecting to vCenter at $vCenterURL ..." -ForegroundColor Cyan
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$handler = [System.Net.Http.HttpClientHandler]::new()
|
$handler = [System.Net.Http.HttpClientHandler]::new()
|
||||||
|
$handler.SslProtocols = [System.Security.Authentication.SslProtocols]::Tls12
|
||||||
$handler.ServerCertificateCustomValidationCallback = { $true }
|
$handler.ServerCertificateCustomValidationCallback = { $true }
|
||||||
|
|
||||||
$client = [System.Net.Http.HttpClient]::new($handler)
|
$client = [System.Net.Http.HttpClient]::new($handler)
|
||||||
|
|||||||
Reference in New Issue
Block a user