[백업][가리사니] c# 인증서 무시
asp/aspx, c#

이 문서는 가리사니 개발자 포럼에 올렸던 글의 백업 파일입니다. 오래된 문서가 많아 현재 상황과 맞지 않을 수 있습니다.

C#에서 인증서를 유효성을 무시하는 코드입니다.

웬만하면 사용하지 않기를 권장합니다. 개발 서버도 요즘은 렛츠인크립트로 발급하여 사용하시면 됩니다. 예를들어 연동되는 협력사가 인증서 발급 의지가 없는 경우...

public static void IgnoreBadCertificates()
{
	System.Net.ServicePointManager.ServerCertificateValidationCallback
	 = new System.Net.Security.RemoteCertificateValidationCallback(AcceptAllCertifications);
}
private static bool AcceptAllCertifications
(
	object sender,
	System.Security.Cryptography.X509Certificates.X509Certificate certification,
	System.Security.Cryptography.X509Certificates.X509Chain chain,
	System.Net.Security.SslPolicyErrors sslPolicyErrors
)
{
	return true;
}
// https 를 쓰기전에 아래 코드를 불러준다.
IgnoreBadCertificates();