Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- This will also work in later versions of powershell with invoke-restmethod/webrequest. It avoids the requirement for a runspace by implementing the handler as native .net:
- if (-not("dummy" -as [type])) {
- add-type -TypeDefinition @"
- using System;
- using System.Net;
- using System.Net.Security;
- using System.Security.Cryptography.X509Certificates;
- public static class Dummy {
- public static bool ReturnTrue(object sender,
- X509Certificate certificate,
- X509Chain chain,
- SslPolicyErrors sslPolicyErrors) { return true; }
- public static RemoteCertificateValidationCallback GetDelegate() {
- return new RemoteCertificateValidationCallback(Dummy.ReturnTrue);
- }
- }
- "@
- }
- [System.Net.ServicePointManager]::ServerCertificateValidationCallback = [dummy]::GetDelegate()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement