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

标签 powershell ssl webclient

本期来自应征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 默认 SSLContext 并让它下载 https 链接吗?

最佳答案

试着把它放在脚本的顶部

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

关于powershell - 如何在 powershell 中为简单的 https 下载设置默认的 Default SSLContext?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38733742/

相关文章:

powershell - Powershell新项目:如何自动接受确认

powershell - 通过命令行将变量传递给 powershell 脚本

java - SOAP SSL 握手

ssl - NGINX SSL 直通无法正常工作?

c# - 下载数千个网页的最有效方法

powershell - 使用 Powershell 从 TFS 获取最新版本的文件夹

windows - 无法将 TLS/SSL 证书加载到 FileZilla Server - "no start line"错误

c# - 如何将代理身份验证详细信息添加到 webclient 对象

windows-phone-7 - 如何忽略 Windows Phone 7 中的证书错误?

email - 释放 send-mailmessage 出错时留下的文件锁