如何在PowerShell中为简单的https下载设置默认的默认SSLContext?

时间:2016-08-03 03:10:05

标签: powershell ssl webclient webclient-download

来自征兵http://www.foundweekends.org/conscript/setup.html的这个问题 当我尝试通过运行官方脚本(setup.ps1 script source code)在我的Windows 10上安装conscript时,我遇到了同事:

 :::: ERRORS
    Server access Error: java.security.NoSuchAlgorithmException: Default SSLContext not available url=https://dl.bintray.com/foundweekends/maven-releases/org/foundweekends/conscript/conscript_2.11/0.5.0/conscript_2.11-0.5.0.pom

    Server access Error: java.security.NoSuchAlgorithmException: Default SSLContext not available url=https://dl.bintray.com/foundweekends/maven-releases/org/foundweekends/conscript/conscript_2.11/0.5.0/conscript_2.11-0.5.0.jar

    Server access Error: java.security.NoSuchAlgorithmException: Default SSLContext not available url=https://oss.sonatype.org/content/repositories/releases/org/foundweekends/conscript/conscript_2.11/0.5.0/conscript_2.11-0.5.0.pom

    Server access Error: java.security.NoSuchAlgorithmException: Default SSLContext not available url=https://oss.sonatype.org/content/repositories/releases/org/foundweekends/conscript/conscript_2.11/0.5.0/conscript_2.11-0.5.0.jar

    Server access Error: java.security.NoSuchAlgorithmException: Default SSLContext not available url=https://repo1.maven.org/maven2/org/foundweekends/conscript/conscript_2.11/0.5.0/conscript_2.11-0.5.0.pom

    Server access Error: java.security.NoSuchAlgorithmException: Default SSLContext not available url=https://repo1.maven.org/maven2/org/foundweekends/conscript/conscript_2.11/0.5.0/conscript_2.11-0.5.0.jar

我认为问题来自:

$wc = New-Object System.Net.WebClient
...
$wc.DownloadFile($url, "$CS/$LJ")

这里有wc对象,但它们没有为下载对象组装SSLContext。

你能举例说明如何提供$ wc defalult SSLContext并可以下载https链接吗?

1 个答案:

答案 0 :(得分:0)

尝试将其放在脚本的顶部

[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}