첨부 소스 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170
using System;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;

#region 서버 인증서 무결성 콜백 처리하기 - serverCertificateValidationCallback(sender, certificate, chain, sslPolicyErrors)

/// <summary>
/// 서버 인증서 무결성 콜백 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="certificate">X509 인증서</param>
/// <param name="chain">X509 체인</param>
/// <param name="sslPolicyErrors">SSL 정책 에러</param>
/// <returns>처리 결과</returns>
private bool serverCertificateValidationCallback(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
    if(sslPolicyErrors == SslPolicyErrors.None)
    {
        return true;
    }

    Console.WriteLine
    (
        "X509Certificate [{0}] Policy Error : {1}",
        certificate.Subject,
        sslPolicyErrors.ToString()
    );

    return false;
}

#endregion

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

ServicePointManager.ServerCertificateValidationCallback += serverCertificateValidationCallback;

using(WebClient client = new WebClient())
{
    client.DownloadFile("https://raw.githubusercontent.com/pjreddie/darknet/master/cfg/yolov3-tiny.cfg", "d:\\yolov3-tiny.cfg");
}
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요