Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 

(시리즈 글이 2개 있습니다.)
.NET Framework: 2091. C# - 웹 사이트가 어떤 버전의 TLS/SSL을 지원하는지 확인하는 방법
; https://www.sysnet.pe.kr/2/0/13237

.NET Framework: 2092. IIS 웹 사이트를 TLS 1.2 또는 TLS 1.3 프로토콜로만 운영하는 방법
; https://www.sysnet.pe.kr/2/0/13238




C# - 웹 사이트가 어떤 버전의 TLS/SSL을 지원하는지 확인하는 방법

C# 코드로 다음과 같이 간단하게 확인할 수 있습니다.

using System;
using System.Net;

internal class Program
{
    static void Main(string[] args)
    {
        string url = "http://blog.rss.naver.com/";

        foreach (SecurityProtocolType value in Enum.GetValues(typeof(SecurityProtocolType)))
        {
            if (value == SecurityProtocolType.SystemDefault)
            {
                continue;
            }

            CheckProtocol(url, value);
        }
    }

    private static void CheckProtocol(string url, SecurityProtocolType value)
    {
        ServicePointManager.SecurityProtocol = value;
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
        try
        {
            request.KeepAlive = false;
            using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
            {
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    using (var stream = new StreamReader(response.GetResponseStream()))
                    {
                        stream.ReadToEnd();
                    }
                }

                Console.WriteLine($"{Enum.GetName(typeof(SecurityProtocolType), value)}({(int)value}): Supported");
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine($"{Enum.GetName(typeof(SecurityProtocolType), value)}({(int)value}): Not supported - {ex.Message}");
        }
    }
}

이 프로그램을 .NET Framework 4.x 환경에서 실행하면 다음과 같은 결과가 나옵니다.

// Windows 11 + .NET Framework 4.x

Ssl3: Supported
Tls: Supported
Tls11: Supported
Tls12: Supported
Tls13: Supported

오호~~~ naver는 모든 프로토콜을 지원하는군요. ^^ 반면 문제가 되었던 RSS를 노출하는 서버로 테스트를 하면,

Ssl3: Not supported - The underlying connection was closed: An unexpected error occurred on a receive.
Tls: Not supported - The request was aborted: Could not create SSL/TLS secure channel.
Tls11: Not supported - The request was aborted: Could not create SSL/TLS secure channel.
Tls12: Supported
Tls13: Supported

보는 바와 같이 TLS 1.2 이상에 대해서만 지원하고 있습니다.




기타, 버전별 닷넷 런타임에서 위의 프로그램을 빌드하고 실행하면 이런 결과가 나옵니다.

// .NET Framework 3.5 이하 + 대상은 naver.com
Ssl3: Supported
Tls: Supported

// .NET Core 2.0 환경에서 실행한 경우 + 대상은 naver.com
Ssl3: Not supported - The requested security protocol is not supported.
Tls: Supported
Tls11: Supported
Tls12: Supported

// .NET Core 3.0 ~ .NET 7 + 대상은 naver.com
Ssl3: Not supported - The requested security protocol is not supported.
Tls: Supported
Tls11: Supported
Tls12: Supported
Tls13: Supported

보는 바와 같이 .NET 3.5 이하의 경우 SecurityProtocolType 타입 자체가 Ssl3/Tls만 가지고 있습니다. 그렇긴 해도 이후의 버전에 대한 상수를 숫자 그대로 입력하면 동작하기 때문에 SSL/TLS 버전으로 인해 .NET 런타임을 고를 필요는 없습니다.

.NET Core의 경우 SecurityProtocolType 타입을 지원하는 최소 버전이 2.0이고, SSL 3.0은 아예 구현에서 제외를 시켰으며 3.0부터는 TLS 1.3 (기능이 아닌 상숫값) 지원을 추가한 정도로 정리가 됩니다.

마지막으로 openssl 프로그램에서도 위와 같은 보안 프로토콜을 테스트할 수 있는데요, 그에 대해서는 다음의 글이 도움이 될 것입니다. ^^

웹/리눅스 서버에서의 TLS / SSL 버전 확인 및 설정 방법 (SSL Labs)
; https://iamfreeman.tistory.com/entry/서버에서의-TLS-SSL-버전-확인-방법




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]







[최초 등록일: ]
[최종 수정일: 6/13/2023]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




1  2  3  4  5  6  7  8  9  10  11  12  13  14  [15]  ...
NoWriterDateCnt.TitleFile(s)
13248정성태2/7/20234052오류 유형: 841. 리눅스 - [사용자 계정] is not in the sudoers file. This incident will be reported.
13247정성태2/7/20234963VS.NET IDE: 180. Visual Studio - 닷넷 소스 코드 디버깅 중 "Decompile source code"가 동작하는 않는 문제
13246정성태2/6/20234089개발 환경 구성: 664. Hyper-V에 설치한 리눅스 VM의 VHD 크기 늘리는 방법 - 두 번째 이야기
13245정성태2/6/20234637.NET Framework: 2093. C# - PEM 파일을 이용한 RSA 개인키/공개키 설정 방법파일 다운로드1
13244정성태2/5/20233989VS.NET IDE: 179. Visual Studio - External Tools에 Shell 내장 명령어 등록
13243정성태2/5/20234856디버깅 기술: 190. windbg - Win32 API 호출 시점에 BP 거는 방법 [1]
13242정성태2/4/20234304디버깅 기술: 189. ASP.NET Web Application (.NET Framework) 프로젝트의 숨겨진 예외 - System.UnauthorizedAccessException
13241정성태2/3/20233827디버깅 기술: 188. ASP.NET Web Application (.NET Framework) 프로젝트의 숨겨진 예외 - System.IO.FileNotFoundException
13240정성태2/1/20233987디버깅 기술: 187. ASP.NET Web Application (.NET Framework) 프로젝트의 숨겨진 예외 - System.Web.HttpException
13239정성태2/1/20233629디버깅 기술: 186. C# - CacheDependency의 숨겨진 예외 - System.Web.HttpException
13238정성태1/31/20235640.NET Framework: 2092. IIS 웹 사이트를 TLS 1.2 또는 TLS 1.3 프로토콜로만 운영하는 방법
13237정성태1/30/20235328.NET Framework: 2091. C# - 웹 사이트가 어떤 버전의 TLS/SSL을 지원하는지 확인하는 방법
13236정성태1/29/20234972개발 환경 구성: 663. openssl을 이용해 인트라넷 IIS 사이트의 SSL 인증서 생성
13235정성태1/29/20234515개발 환경 구성: 662. openssl - 윈도우 환경의 명령행에서 SAN 적용하는 방법
13234정성태1/28/20235561개발 환경 구성: 661. dnSpy를 이용해 소스 코드가 없는 .NET 어셈블리의 코드를 변경하는 방법 [1]
13233정성태1/28/20236904오류 유형: 840. C# - WebClient로 https 호출 시 "The request was aborted: Could not create SSL/TLS secure channel" 예외 발생
13232정성태1/27/20234704스크립트: 43. uwsgi의 --processes와 --threads 옵션
13231정성태1/27/20233618오류 유형: 839. python - TypeError: '...' object is not callable
13230정성태1/26/20234031개발 환경 구성: 660. WSL 2 내부로부터 호스트 측의 네트워크로 UDP 데이터가 1개의 패킷으로만 제한되는 문제
13229정성태1/25/20234974.NET Framework: 2090. C# - UDP Datagram의 최대 크기
13228정성태1/24/20235119.NET Framework: 2089. C# - WMI 논리 디스크가 속한 물리 디스크의 정보를 얻는 방법 [2]파일 다운로드1
13227정성태1/23/20234824개발 환경 구성: 659. Windows - IP MTU 값을 바꿀 수 있을까요? [1]
13226정성태1/23/20234497.NET Framework: 2088. .NET 5부터 지원하는 GetRawSocketOption 사용 시 주의할 점
13225정성태1/21/20233749개발 환경 구성: 658. Windows에서 실행 중인 소켓 서버를 다른 PC 또는 WSL에서 접속할 수 없는 경우
13224정성태1/21/20234097Windows: 221. Windows - Private/Public/Domain이 아닌 네트워크 어댑터 단위로 방화벽을 on/off하는 방법
13223정성태1/20/20234288오류 유형: 838. RDP 연결 오류 - The two computers couldn't connect in the amount of time allotted
1  2  3  4  5  6  7  8  9  10  11  12  13  14  [15]  ...