flo*_*oyd 3 .net rest powershell https
我试图测试一个非常简单的PowerShell脚本来从内部票务站点获取/发布数据.我遇到的问题似乎与所需的SSL证书有关.有人可以帮我理解我需要添加哪些代码才能使其工作?
谢谢
返回错误:使用"0"参数调用"GetResponse"的异常:"底层连接已关闭:无法为SSL/TLS安全通道建立信任关系."
现行代码:
$url = "https://username:password@IPADDRESS/ticket"
$command = get-content jsonfile.json
$bytes = [System.Text.Encoding]::ASCII.GetBytes($command)
$web = [System.Net.WebRequest]::Create($url)
$web.Method = "POST"
$web.ContentLength = $bytes.Length
$web.ContentType = "application/json"
$stream = $web.GetRequestStream()
$stream.Write($bytes,0,$bytes.Length)
$stream.close()
$reader = New-Object System.IO.Streamreader -ArgumentList
$web.GetResponse().GetResponseStream()
$reader.ReadToEnd()
$reader.Close()
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4897 次 |
最近记录: |