1

PowerShell 4.0
Windows 服务器 2012 R2

你好,我有一个获取令牌的握手方法,比如

$response = Invoke-WebRequest -Uri "https://**.**.**.**:port/token/" -Method GET -Headers @{Authorization = "Basic blahblahblah"} -Body @{grant_type="client_credentials"} 

然后我有一个错误

Invoke-WebRequest:请求被中止:无法创建 SSL/TLS 安全通道

邮递员和 CURL 正在工作,有人知道如何在 POSH 脚本中禁用证书检查吗?

以下事情对我没有帮助

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;
    }
}
"@
$AllProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12'
[System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
4

0 回答 0