NetboxPS/Functions/Setup/Set-NetboxUnstrustedSSL.ps1
Alexis La Goutte c8233ab572 Add Set-NetboxUnstrustedSSL for disable SSL chain test (for PS 5.0
From PowerAruba/FortiPwoer Module :)
2021-07-21 23:06:17 +02:00

19 lines
No EOL
696 B
PowerShell

Function Set-NetboxUntrustedSSL {
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessforStateChangingFunctions", "")]
Param( )
# Hack for allowing untrusted SSL certs with https connections
Add-Type -TypeDefinition @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object -TypeName TrustAllCertsPolicy
}