1. C#의 ServicePointManager 설정 문제
using System;
using System.Net;
using System.Net.Http;
using System.Security.Cryptography.X509Certificates;
class Program
{
static void Main()
{
// TLS 1.2 이상을 활성화
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls13;
// SSL/TLS 인증서 검증 우회 (테스트용, 실제 운영에서는 사용 X)
ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
using (HttpClient client = new HttpClient())
{
try
{
var response = client.GetAsync("<https://example.com>").Result;
Console.WriteLine(response.StatusCode);
}
catch (Exception ex)
{
Console.WriteLine("오류 발생: " + ex.Message);
}
}
}
}
2. 제어판 → 인터넷 옵션 → 고급 → 보안 → TLS 1.1 , TLS 1.2 체크
3. 신뢰할 수 있는 루트 인증서, 신뢰할 수 있는 중간 인증서 문제
→ Let’s Encrypt 관련 문제가 발생할 수 있음 ( 특히 Windows Update 를 사용하지 않는 PC 에서 문제가 발생할 가능성이 높음 )
→ 방법 3이 처리하기 편합니다. ( 재부팅 없이 즉시 사용 )
→ 방법 3을 실행하는 배치 파일 : ( Windows 10 이하에서는 파워쉘 관련 설정이 필요할 수 있습니다. )
3.1. 방법 1: Windows 자동 업데이트로 인증서 갱신하기
- Windows 업데이트 실행
- Win + R → ms-settings:windowsupdate 입력 → Enter
- "업데이트 확인" 버튼을 눌러 최신 보안 업데이트를 설치합니다.
- 업데이트 후 PC 재부팅
- 최신 루트 인증서가 자동으로 갱신됩니다.
- Windows 업데이트가 불가능한 경우 방법 2를 사용하세요.
3.2. 방법 2: Let's Encrypt 공식 인증서 직접 다운로드 및 설치
- Let's Encrypt 공식 사이트에 접속
- 아래 두 개의 루트 인증서를 다운로드하세요.
- https://letsencrypt.org/certificates/
- ISRG Root X1 (PEM)
- ISRG Root X2 (PEM)
- 아래 두 개의 루트 인증서를 다운로드하세요.
- 파일 확장자를 .crt로 변경
- isrgrootx1.pem → isrgrootx1.crt
- isrg-root-x2.pem → isrg-root-x2.crt
- 파일을 더블 클릭하여 설치 진행
- "인증서 설치" 클릭
- "로컬 컴퓨터" 선택 후 "다음"
- "신뢰할 수 있는 루트 인증 기관" 선택 후 "다음"
- "마침"을 눌러 설치 완료
- 설치 후 PC를 재부팅하고 C# 프로그램 실행
3.3. 방법 3: certutil 명령어로 인증서 갱신 (고급 사용자용)
Windows에서 명령어 한 줄로 최신 루트 인증서를 가져와 설치할 수도 있습니다.
- 관리자 권한으로 PowerShell 또는 CMD 실행
- 아래 명령어 입력 후 Enter
- certutil -generateSSTFromWU root.sst certutil -addstore -f root root.sst
- 완료되면 root.sst 파일을 삭제해도 됩니다.
'.Net Framework Standard' 카테고리의 다른 글
[C#] 오류 처리 - TLS 버전 (0) | 2022.10.21 |
---|---|
[C#] WebService .asmx 오류 전역 (예외)처리 (1) | 2019.06.17 |
[ClickOnce] 배포 후 업데이트 오류시- 폴더 삭제 혹은 Registry 삭제 (0) | 2018.08.28 |
Visual Studio에서 찾기 / 바꾸기 기능에서 정규식 사용 방법.. (1) | 2018.04.06 |
Visual Studio 2012 Web Project Debuging 시 IIS Express 64bit 사용하기 (0) | 2017.08.11 |