techthoughts2
5/24/2017 - 10:04 PM

This code block can be used to permit Invoke-WebRequest to work with SSL addresses that don't have a trusted certificate authority

This code block can be used to permit Invoke-WebRequest to work with SSL addresses that don't have a trusted certificate authority

##############################################################
	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
	##############################################################