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

비밀번호

댓글 작성자
 




[1]  2  3  4  5  6  7  8  9  10  11  12  13  14  15  ...
NoWriterDateCnt.TitleFile(s)
13608정성태4/26/2024417닷넷: 2249. C# - 부모의 필드/프로퍼티에 대해 서로 다른 자식 클래스 간에 Reflection 접근이 동작할까요?파일 다운로드1
13607정성태4/25/2024415닷넷: 2248. C# - 인터페이스 타입의 다중 포인터를 인자로 갖는 C/C++ 함수 연동
13606정성태4/24/2024431닷넷: 2247. C# - tensorflow 연동 (MNIST 예제)파일 다운로드1
13605정성태4/23/2024675닷넷: 2246. C# - Python.NET을 이용한 파이썬 소스코드 연동파일 다운로드1
13604정성태4/22/2024699오류 유형: 901. Visual Studio - Unable to set the next statement. Set next statement cannot be used in '[Exception]' call stack frames.
13603정성태4/21/2024875닷넷: 2245. C# - IronPython을 이용한 파이썬 소스코드 연동파일 다운로드1
13602정성태4/20/2024938닷넷: 2244. C# - PCM 오디오 데이터를 연속(Streaming) 재생 (Windows Multimedia)파일 다운로드1
13601정성태4/19/2024966닷넷: 2243. C# - PCM 사운드 재생(NAudio)파일 다운로드1
13600정성태4/18/2024975닷넷: 2242. C# - 관리 스레드와 비관리 스레드
13599정성태4/17/2024936닷넷: 2241. C# - WAV 파일의 PCM 사운드 재생(Windows Multimedia)파일 다운로드1
13598정성태4/16/2024979닷넷: 2240. C# - WAV 파일 포맷 + LIST 헤더파일 다운로드2
13597정성태4/15/2024973닷넷: 2239. C# - WAV 파일의 PCM 데이터 생성 및 출력파일 다운로드1
13596정성태4/14/20241079닷넷: 2238. C# - WAV 기본 파일 포맷파일 다운로드1
13595정성태4/13/20241069닷넷: 2237. C# - Audio 장치 열기 (Windows Multimedia, NAudio)파일 다운로드1
13594정성태4/12/20241083닷넷: 2236. C# - Audio 장치 열람 (Windows Multimedia, NAudio)파일 다운로드1
13593정성태4/8/20241090닷넷: 2235. MSBuild - AccelerateBuildsInVisualStudio 옵션
13592정성태4/2/20241226C/C++: 165. CLion으로 만든 Rust Win32 DLL을 C#과 연동
13591정성태4/2/20241201닷넷: 2234. C# - WPF 응용 프로그램에 Blazor App 통합파일 다운로드1
13590정성태3/31/20241083Linux: 70. Python - uwsgi 응용 프로그램이 k8s 환경에서 OOM 발생하는 문제
13589정성태3/29/20241158닷넷: 2233. C# - 프로세스 CPU 사용량을 나타내는 성능 카운터와 Win32 API파일 다운로드1
13588정성태3/28/20241275닷넷: 2232. C# - Unity + 닷넷 App(WinForms/WPF) 간의 Named Pipe 통신 [2]파일 다운로드1
13587정성태3/27/20241361오류 유형: 900. Windows Update 오류 - 8024402C, 80070643
13586정성태3/27/20241534Windows: 263. Windows - 복구 파티션(Recovery Partition) 용량을 늘리는 방법
13585정성태3/26/20241497Windows: 262. PerformanceCounter의 InstanceName에 pid를 추가한 "Process V2"
13584정성태3/26/20241457개발 환경 구성: 708. Unity3D - C# Windows Forms / WPF Application에 통합하는 방법파일 다운로드1
[1]  2  3  4  5  6  7  8  9  10  11  12  13  14  15  ...