첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

■ HttpClient 클래스 사용시 특정 인증서 오류를 무시하는 방법을 보여준다.

 

▶ 예제 코드 (C#)

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;
    }
}
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요