我正在尝试使用PowerShell脚本将appx上传到曲棍球应用。 当我运行PowerShell脚本时出现以下错误:
Invoke-RestMethod : The underlying connection was closed: Could not establish
trust relationship for the SSL/TLS secure channel.
At C:\PROG\WorkWise-Windows\UploadToHokeyScript\HockeyApp_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
非常感谢帮助。
答案 0 :(得分:0)
在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