2024年9月11日 星期三

和SSL連線有關的設定

HTTPS連線,不管是在寫sql clr或者powershell,每次遇到以下二類SSL錯誤,都忘了要改啥。這次記錄下,以後可以參考。

System.Net.WebException: 基礎連接已關閉: 接收時發生未預期的錯誤。 ---> System.ComponentModel.Win32Exception: 用戶端和伺服器無法溝通,因為它們沒有公用的演算法

加入以下

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12| SecurityProtocolType.Tls13;

System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: 基礎連接已關閉: 無法為 SSL/TLS 安全通道建立信任關係。 ---> System.Security.Authentication.AuthenticationException: 根據驗證程序,遠端憑證是無效的。

加入以下:

ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

順便再加一段sql clr assembly,單純的呼叫GET方法 WEB URL,回傳respone內容。


沒有留言:

張貼留言

pdf.js 無法顯示部份字

有個檔案在pdf viewer套件中無法顯示內容,但下載檔案後使用工具又可以正常顯示。 本來以為是套件版本太舊的原因,於是去下載pdf viewer套件 https://github.com/mozilla/pdf.js 更新後還是一樣。 覺得應是字型缺漏的問題,於是用PDF-X...