The request was aborted: Could not create SSL/TLS secure channel


一、背景:

公司底層服務CDN從Akamai遷移到阿里雲之后, 使用該服務的一個應用報錯如下:

System.AggregateException: One or more errors occurred. ---> System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel.
   at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context)
   at System.Net.Http.HttpClientHandler.GetRequestStreamCallback(IAsyncResult ar)

二、排查步驟:

  1、使用Postman測試接口沒有問題.

  2、本地調試發現HttpClient不能獲取返回結果, 兩種情況, 一種請求壓根沒發出去, 第二種是在網絡層面被拒絕了.

  3、從報錯信息來看, 個人感覺是第二種, 看上去像是網絡協議的問題.

三、解決辦法:

定位了問題就好辦了, 網上一查便知, 添加了如下代碼:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
        | SecurityProtocolType.Tls11
        | SecurityProtocolType.Tls12
        | SecurityProtocolType.Ssl3;


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM