我尝试使用以下代码从防火墙请求XML文件。
$result = Invoke-WebRequest "https://IpAddress"
我收到此错误: Invoke-WebRequest:基础连接已关闭:发送时发生意外错误。
我尝试过:
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]::ServerCertificateValidationCallback = {$true}
它仍然无法正常工作。 问候