■ HttpClient 클래스 사용시 특정 인증서 오류를 무시하는 방법을 보여준다.
▶ 예제 코드 (C#)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
using System.Net.Security; using(HttpClientHandler httpClientHandler = new HttpClientHandler()) { httpClientHandler.ServerCertificateCustomValidationCallback = (message, certificates, chain, sslPolicyErrors) => { if(sslPolicyErrors == SslPolicyErrors.None) { return true; } if(certificates.GetCertHashString() == "99E92D8447AEF30483B1D7527812C9B7B3A915A7") { return true; } return false; }; using(HttpClient httpClient = new HttpClient(httpClientHandler)) { HttpResponseMessage responseMessage = httpClient.GetAsync("https://example.com").Result; } } |