Quantcast
Channel: THWACK: Message List
Viewing all articles
Browse latest Browse all 20396

Re: HTTPS Application Monitor - Need to run script with this monitor.

$
0
0

What about telling PowerShell to just ignore SSL? http://poshcode.org/624

 

I used the above "snippet" in a slightly different way when I had to write something that pulled information out of Exchange Web Services.  This script (not the snippet) is my crowning glory in regards to PowerShell & Exchange Web Services.  It could have been optimized a little better, but it did what it was supposed to do.

 

#region PoshCode #624 - Trust all SSL Certificates
## Shamelessly stolen from PowerShell Code Website
## Source: http://poshcode.org/624
$Provider = New-Object-TypeNameMicrosoft.CSharp.CSharpCodeProvider
$Compiler = $Provider.CreateCompiler()
$Params = New-Object -TypeName System.CodeDom.Compiler.CompilerParameters
$Params.GenerateExecutable      = $False
$Params.GenerateInMemory        = $True
$Params.IncludeDebugInformation = $False
$Params.ReferencedAssemblies.Add("System.DLL") |Out-Null

 

$TASource = @'
  namespace Local.ToolkitExtensions.Net.CertificatePolicy{
    public class TrustAll : System.Net.ICertificatePolicy {
      public TrustAll() {
      }
    public bool CheckValidationResult(System.Net.ServicePoint sp,
      System.Security.Cryptography.X509Certificates.X509Certificate cert,
      System.Net.WebRequest req, int problem) {
      return true;
    }
  }
}
'@
$TAResults  = $Provider.CompileAssemblyFromSource($Params,$TASource)
$TAAssembly = $TAResults.CompiledAssembly
## We now create an instance of the TrustAll and attach it to the ServicePointManager
$TrustAll = $TAAssembly.CreateInstance("Local.ToolkitExtensions.Net.CertificatePolicy.TrustAll")
[System.Net.ServicePointManager]::CertificatePolicy = $TrustAll
#endregion PoshCode #624 - Trust all SSL Certificates


Viewing all articles
Browse latest Browse all 20396

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>