Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. 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:
  4.  
  5. if (-not("dummy" -as [type])) {
  6.     add-type -TypeDefinition @"
  7. using System;
  8. using System.Net;
  9. using System.Net.Security;
  10. using System.Security.Cryptography.X509Certificates;
  11.  
  12. public static class Dummy {
  13.    public static bool ReturnTrue(object sender,
  14.        X509Certificate certificate,
  15.        X509Chain chain,
  16.        SslPolicyErrors sslPolicyErrors) { return true; }
  17.  
  18.    public static RemoteCertificateValidationCallback GetDelegate() {
  19.        return new RemoteCertificateValidationCallback(Dummy.ReturnTrue);
  20.    }
  21. }
  22. "@
  23. }
  24.  
  25. [System.Net.ServicePointManager]::ServerCertificateValidationCallback = [dummy]::GetDelegate()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement