HttpClient
ใน .NET Core เมื่อ Request API ที่ใช้ Self-signed certificate (ปกติจะ Sign ไว้สำหรับทดสอบโปรแกรมบน localhost) จะไม่สามารถทำได้ เนื่องจากโปรแกรม Validate SSL ไม่ผ่าน โดยจะเกิด Exception ดังนี้
System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception.
---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.
วิธีแก้ Exception ให้ปรับ ServerCertificateCustomValidationCallback
ของ HttpClientHandler
เป็น DangerousAcceptAnyServerCertificateValidator
ตามตัวอย่าง