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

(시리즈 글이 6개 있습니다.)
.NET Framework: 490. System.Data.SqlClient는 SSL 3.0/TLS 1.0만 지원하는 듯!
; https://www.sysnet.pe.kr/2/0/1833

개발 환경 구성: 254. SQL 서버 역시 SSL 3.0/TLS 1.0만을 지원하는 듯!
; https://www.sysnet.pe.kr/2/0/1835

.NET Framework: 2127. C# - Ubuntu + Microsoft.Data.SqlClient + SQL Server 2008 R2 연결 방법
; https://www.sysnet.pe.kr/2/0/13364

개발 환경 구성: 678. openssl로 생성한 인증서를 SQL Server의 암호화 인증서로 설정하는 방법
; https://www.sysnet.pe.kr/2/0/13368

개발 환경 구성: 680. C# - Ubuntu + Microsoft.Data.SqlClient + SQL Server 2008 R2 연결 방법 - TLS 1.2 지원
; https://www.sysnet.pe.kr/2/0/13370

개발 환경 구성: 682. SQL Server TLS 통신을 위해 사용되는 키 길이 확인 방법
; https://www.sysnet.pe.kr/2/0/13372




C# - Ubuntu + Microsoft.Data.SqlClient + SQL Server 2008 R2 연결 방법 - TLS 1.2 지원

지난 글에서,

C# - Ubuntu + Microsoft.Data.SqlClient + SQL Server 2008 R2 연결 방법
; https://www.sysnet.pe.kr/2/0/13364

리눅스 환경인 경우 SqlConnection 접속에서 TLS 1.2를 지원하지 않아 "CipherString = DEFAULT:@SECLEVEL" 값을 재조정하는 것으로 해결했습니다.

하지만, 분명히 문서상으로는 TLS 1.2를 지원한다고 되어 있는데요, 어디... ^^ 정말 그런 것인지 테스트를 해볼까요?




초기 SQL Server 2008 R2는 TLS 1.2를 지원하지 않습니다. 당연히 업데이트가 필요한데, 이를 위해 우선 (KB2979597에 해당하는) Service Pack 3을 설치해야 합니다. 그럼 SQL Server 2008 R2 버전이 10.50.6000.34로 바뀝니다. (패치에 따른 버전 참조: Microsoft SQL Server 2008 R2 Versions)

일단 SP3을 설치하면 이어서 KB3045316 중요 업데이트로 떠오르고, 이것을 완료하면 SQL Server 2008 R2 버전은 10.50.6220.0이 됩니다. 그리고 마침내, 우리가 원하는 TLS 1.2 지원 패치가 KB3135244에 해당하는데요,

KB3135244 - TLS 1.2 support for Microsoft SQL Server
; https://support.microsoft.com/en-us/topic/kb3135244-tls-1-2-support-for-microsoft-sql-server-e4472ef8-90a9-13c1-e4d8-44aad198cdbe

TLS 1.2 Support is available in the latest cumulative update for SQL Server 2008 R2 SP3 – KB4057113.

이것은 KB4057113 누적 업데이트에 포함됐다고 나옵니다.

Security Update for SQL Server 2008 R2 SP3 (KB4057113)
; https://www.microsoft.com/en-us/download/details.aspx?id=56415

따라서 최종 준비는 위의 업데이트를 설치하는 것으로 마무리할 수 있습니다. 그리고 위의 업데이트를 설치하면 SQL Server 2008 R2의 버전이 10.50.6560.0으로 바뀝니다.

실제로 이 시점부터는, Windows 클라이언트에서의 "Microsoft.Data.SqlClient"로 접속했을 때 "Security Warning: The negotiated TLS 1.0 is an insecure protocol and is supported for backward compatibility only. The recommended protocol version is TLS 1.2 and later." 경고가 사라집니다.

결국 KB4057113으로 TLS 1.2 지원이 되는 것은 맞는 것 같습니다. 관련해 아래의 Q&A를 보면,

KB3135244 - TLS 1.2 support for Microsoft SQL Server
; https://support.microsoft.com/en-us/topic/kb3135244-tls-1-2-support-for-microsoft-sql-server-e4472ef8-90a9-13c1-e4d8-44aad198cdbe

Q: Will SQL Server 2005 be supported for TLS 1.2?
A: TLS 1.2 support is offered only for SQL Server 2008 and later versions.

Q: Which versions of Windows Server support TLS 1.2?
A: Windows Server 2008 R2 and later versions support TLS 1.2.

분명하게 2008 버전부터 지원한다고 나옵니다. 단지, 여전히 Ubuntu에서의 연결은 SECLEVEL을 설정하지 않으면 아래의 예외가 발생하는데요,

Unhandled exception. Microsoft.Data.SqlClient.SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: SSL Provider, error: 31 - Encryption(ssl/tls) handshake failed)
 ---> System.IO.IOException:  Received an unexpected EOF or 0 bytes from the transport stream.

도대체 왜 리눅스에서의 접근에는 오류가 발생하는 것일까요? ^^




이를 위해 우선 SECLEVEL의 의미부터 알아야 할 필요가 있습니다. 지난 글에 정리한 것처럼, Ubuntu 20.04의 경우 Level 1에서 정상 동작했으므로 기본값인 Level 2를 만족하지 못했다는 것인데요, 이것의 의미를 보면,

Security level set to 112 bits of security. As a result RSA, DSA and DH keys shorter than 2048 bits and ECC keys shorter than 224 bits are prohibited. In addition to the level 1 exclusions any cipher suite using RC4 is also prohibited. SSL version 3 is also not allowed. Compression is disabled.


2048비트보다 짧은 키 길이는 허용하지 않는다고 나옵니다. 그렇다면 아마도 SQL Server 2008 R2의 암호화에 사용하는 기본 인증서가 2048보다 낮게 나온다고 추측할 수 있습니다. 확인을 위해 지난 글에 소개한 get_tds_cert.py를 이용해 추출한 인증서를 보면,

sql2008_tls12_1.png

오호~~~ 예상이 맞아떨어졌습니다. 실제로 지난 글에 설명한 방법을 거쳐 2048비트의 키 길이를 갖는 인증서를 만들어 SQL Server 2008 R2에 제공하면, SECLEVEL=2 상황에서도 SqlConnection 연결이 잘 되는 것을 확인할 수 있습니다. ^^

// Ubuntu 22.04 환경

$ cat /etc/ssl/openssl.cnf

...[생략]...

[system_default_sect]
CipherString = DEFAULT:@SECLEVEL=2

$ cat Program.cs
using Microsoft.Data.SqlClient;

// Install-Package Microsoft.Data.SqlClient
internal class Program
{
    static void Main(string[] args)
    {
        SqlConnection conn = new SqlConnection("TrustServerCertificate=true; User ID=testusr;Password=testusr_pw;Persist Security Info=False;Initial Catalog=TestDB2;Data Source=testpc");
        conn.Open();
        Console.WriteLine(conn.ServerVersion);
        conn.Close();
    }
}

$ dotnet run ConsoleApp1.csproj
10.50.6560

클라이언트마다 SECLEVEL을 조정하느냐, SQL 서버 측에 한 번의 인증서 설정을 하느냐는... 여러분이 선택하시면 되겠습니다. ^^




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







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

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

비밀번호

댓글 작성자
 




... 16  17  18  [19]  20  21  22  23  24  25  26  27  28  29  30  ...
NoWriterDateCnt.TitleFile(s)
13158정성태11/9/20225270오류 유형: 826. Workload definition 'wasm-tools' in manifest 'microsoft.net.workload.mono.toolchain' [...] conflicts with manifest 'microsoft.net.workload.mono.toolchain.net7'
13157정성태11/8/20225945.NET Framework: 2065. C# - Mutex의 비동기 버전파일 다운로드1
13156정성태11/7/20226838.NET Framework: 2064. C# - Mutex와 Semaphore/SemaphoreSlim 차이점파일 다운로드1
13155정성태11/4/20226349디버깅 기술: 183. TCP 동시 접속 (연결이 아닌) 시도를 1개로 제한한 서버
13154정성태11/3/20225840.NET Framework: 2063. .NET 5+부터 지원되는 GC.GetGCMemoryInfo파일 다운로드1
13153정성태11/2/20227125.NET Framework: 2062. C# - 코드로 재현하는 소켓 상태(SYN_SENT, SYN_RECV)
13152정성태11/1/20225739.NET Framework: 2061. ASP.NET Core - DI로 추가한 클래스의 초기화 방법 [1]
13151정성태10/31/20225874C/C++: 161. Windows 11 환경에서 raw socket 테스트하는 방법파일 다운로드1
13150정성태10/30/20225908C/C++: 160. Visual Studio 2022로 빌드한 C++ 프로그램을 위한 다른 PC에서 실행하는 방법
13149정성태10/27/20225846오류 유형: 825. C# - CLR ETW 이벤트 수신이 GCHeapStats_V1/V2에 대해 안 되는 문제파일 다운로드1
13148정성태10/26/20225811오류 유형: 824. msbuild 에러 - error NETSDK1005: Assets file '...\project.assets.json' doesn't have a target for 'net5.0'. Ensure that restore has run and that you have included 'net5.0' in the TargetFramew
13147정성태10/25/20224907오류 유형: 823. Visual Studio 2022 - Unable to attach to CoreCLR. The debugger's protocol is incompatible with the debuggee.
13146정성태10/24/20225755.NET Framework: 2060. C# - Java의 Xmx와 유사한 힙 메모리 최댓값 제어 옵션 HeapHardLimit
13145정성태10/21/20226033오류 유형: 822. db2 - Password validation for user db2inst1 failed with rc = -2146500508
13144정성태10/20/20225850.NET Framework: 2059. ClrMD를 이용해 윈도우 환경의 메모리 덤프로부터 닷넷 모듈을 추출하는 방법파일 다운로드1
13143정성태10/19/20226389오류 유형: 821. windbg/sos - Error code - 0x000021BE
13142정성태10/18/20225338도서: 시작하세요! C# 12 프로그래밍
13141정성태10/17/20226898.NET Framework: 2058. [in,out] 배열을 C#에서 C/C++로 넘기는 방법 - 세 번째 이야기파일 다운로드1
13140정성태10/11/20226269C/C++: 159. C/C++ - 리눅스 환경에서 u16string 문자열을 출력하는 방법 [2]
13139정성태10/9/20226077.NET Framework: 2057. 리눅스 환경의 .NET Core 3/5+ 메모리 덤프로부터 모든 닷넷 모듈을 추출하는 방법파일 다운로드1
13138정성태10/8/20227367.NET Framework: 2056. C# - await 비동기 호출을 기대한 메서드가 동기로 호출되었을 때의 부작용 [1]
13137정성태10/8/20225728.NET Framework: 2055. 리눅스 환경의 .NET Core 3/5+ 메모리 덤프로부터 닷넷 모듈을 추출하는 방법
13136정성태10/7/20226306.NET Framework: 2054. .NET Core/5+ SDK 설치 없이 dotnet-dump 사용하는 방법
13135정성태10/5/20226543.NET Framework: 2053. 리눅스 환경의 .NET Core 3/5+ 메모리 덤프를 분석하는 방법 - 두 번째 이야기
13134정성태10/4/20225274오류 유형: 820. There is a problem with AMD Radeon RX 5600 XT device. For more information, search for 'graphics device driver error code 31'
13133정성태10/4/20225598Windows: 211. Windows - (commit이 아닌) reserved 메모리 사용량 확인 방법 [1]
... 16  17  18  [19]  20  21  22  23  24  25  26  27  28  29  30  ...