使用Powershell v3的Invoke-WebRequest和Invoke-RestMethod,我成功地使用POST方法將json文件發(fā)布到https網(wǎng)站。我正在使用的命令是 $cert=New-Object System.Security.Cryptography.X509Certificates.X509Certificate2("cert.crt") Invoke-WebRequest -Uri https://IPADDRESS/resource -Credential $cred -certificate $cert -Body $json -ContentType application/json -Method POST但是,當(dāng)我嘗試使用GET方法時(shí): Invoke-WebRequest -Uri https://IPADDRESS/resource -Credential $cred -certificate $cert -Method GET返回以下錯(cuò)誤 Invoke-RestMethod : The underlying connection was closed: An unexpected error occurred on a send. At line:8 char:11 + $output = Invoke-RestMethod -Uri https://IPADDRESS/resource -Credential $cred + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand我嘗試使用以下代碼忽略SSL證書,但不確定它是否真正在做任何事情。 [System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}有人可以提供一些有關(guān)這里可能出什么問題以及如何解決的指導(dǎo)嗎?謝謝
Powershell v3 Invoke-WebRequest HTTPS錯(cuò)誤
慕標(biāo)琳琳
2019-11-28 10:30:56