Skip to content

Instantly share code, notes, and snippets.

@amandadebler
Created March 23, 2018 15:34
Show Gist options
  • Save amandadebler/8e5124c9486b732316679746168c90b8 to your computer and use it in GitHub Desktop.
Save amandadebler/8e5124c9486b732316679746168c90b8 to your computer and use it in GitHub Desktop.
$AllProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12'
[System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols
Add-Type -AssemblyName System.Web
Add-Type -AssemblyName system.Security
Add-Type -AssemblyName System
Add-Type @"
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 TrustAllCertsPolicy
@amandadebler
Copy link
Author

Get PowerShell to ignore SSL errors for Invoke-WebRequest and (possibly) Invoke-RestMethod. Useful when testing responses from individual servers behind a load balancer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment