曲棍球上传错误: 调用休息方法: 基础连接已关闭: 无法建立



我正在尝试使用PowerShell脚本将appx上传到曲棍球应用程序。 当我运行PowerShell脚本时出现以下错误:

Invoke-RestMethod : The underlying connection was closed: Could not establish 
trust relationship for the SSL/TLS secure channel.
At C:PROGWorkWise-WindowsUploadToHokeyScriptHockeyApp_HPWorkWiseTrayUploadS
cript.ps1:20 char:13
+ $response = Invoke-RestMethod -Method POST -Uri $create_url -Header @ ...
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:Htt 
pWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShe 
ll.Commands.InvokeRestMethodCommand

感谢帮助。

在 Invoke-restMethod -Uri 之上添加以下步骤

add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy 
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

最新更新