Skip to content

Instantly share code, notes, and snippets.

@ranadiprony
Last active January 30, 2017 16:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ranadiprony/91bba6ad545d9834e80cbe80798796bb to your computer and use it in GitHub Desktop.
Save ranadiprony/91bba6ad545d9834e80cbe80798796bb to your computer and use it in GitHub Desktop.
Powershell Script for Ignoring the Self Signed Certificates
function Ignore-SelfSignedCerts
{
try
{
Write-Host "Adding TrustAllCertsPolicy type." -ForegroundColor White
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;
}
}
"@
Write-Host "TrustAllCertsPolicy type added." -ForegroundColor White
}
catch
{
Write-Host $_ -ForegroundColor "Yellow"
}
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment