tags:

views:

1582

answers:

2

I'm making an automated script to read a list from a site posting the latest compiled code. That's the part I've already figured out. The next part of the script is to grab that compiled code from a server with an Untrusted Cert.

This is how I'm going about grabbing the file: $web = new-object System.Net.WebClient $web.DownloadFile("https://uri/file.msi", "installer.msi")

Then I get the following error:

Exception calling "DownloadFile" with "2" argument(s): "The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel."

I know I'm missing something, but I can't get the correct way to search for it.

+2  A: 

You need to write a callback handler for ServicePointManager.ServerCertificateValidationCallback.

Brad Wilson
This is correct. I had to create a ConsoleApp to allow me to do this. I could no longer beat my brains in figuring it out in powershell.
+3  A: 

Brad is correct, but notice that PowerShell V1 doesn't really have native support for delegates, which you'll need in this specific case. I believe this should get you around that limitation (in fact the scenario you describe is exactly one of the examples used).

tomasr