.Net Framework Standard

기본 연결이 닫혔습니다. SSL/TLS 보안 채널에 대한 트러스트 관계를 설정할 수 없습니다. ( fit. Let's Encrypt )

달빛에취하다 2025. 2. 7. 11:33

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 이하에서는 파워쉘 관련 설정이 필요할 수 있습니다. )

root 인증서 업데이트.bat
0.00MB

 

3.1. 방법 1: Windows 자동 업데이트로 인증서 갱신하기

  1. Windows 업데이트 실행
    • Win + R → ms-settings:windowsupdate 입력 → Enter
    • "업데이트 확인" 버튼을 눌러 최신 보안 업데이트를 설치합니다.
  2. 업데이트 후 PC 재부팅
    • 최신 루트 인증서가 자동으로 갱신됩니다.
    • Windows 업데이트가 불가능한 경우 방법 2를 사용하세요.

3.2. 방법 2: Let's Encrypt 공식 인증서 직접 다운로드 및 설치

  1. Let's Encrypt 공식 사이트에 접속
  2. 파일 확장자를 .crt로 변경
    • isrgrootx1.pem → isrgrootx1.crt
    • isrg-root-x2.pem → isrg-root-x2.crt
  3. 파일을 더블 클릭하여 설치 진행
    • "인증서 설치" 클릭
    • "로컬 컴퓨터" 선택 후 "다음"
    • "신뢰할 수 있는 루트 인증 기관" 선택 후 "다음"
    • "마침"을 눌러 설치 완료
  4. 설치 후 PC를 재부팅하고 C# 프로그램 실행

3.3. 방법 3: certutil 명령어로 인증서 갱신 (고급 사용자용)

Windows에서 명령어 한 줄로 최신 루트 인증서를 가져와 설치할 수도 있습니다.

  1. 관리자 권한으로 PowerShell 또는 CMD 실행
  2. 아래 명령어 입력 후 Enter
  3. certutil -generateSSTFromWU root.sst certutil -addstore -f root root.sst
  4. 완료되면 root.sst 파일을 삭제해도 됩니다.