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)
13037정성태4/25/20226373.NET Framework: 1998. Azure Functions를 사용한 간단한 실습
13036정성태4/24/20227127.NET Framework: 1997. C# - nano 시간을 가져오는 방법 [2]
13035정성태4/22/20227707Windows: 204. Windows 10부터 바뀐 QueryPerformanceFrequency, QueryPerformanceCounter
13034정성태4/21/20227043.NET Framework: 1996. C# XingAPI - 주식 종목에 따른 PBR, PER, ROE, ROA 구하는 방법(t3320, t8430 예제)파일 다운로드1
13033정성태4/18/20227639.NET Framework: 1195. C# - Thread.Yield와 Thread.Sleep(0)의 차이점(?)
13032정성태4/17/20227358오류 유형: 805. Github의 50MB 파일 크기 제한 - warning: GH001: Large files detected. You may want to try Git Large File Storage
13031정성태4/15/20226916.NET Framework: 1194. C# - IdealProcessor와 ProcessorAffinity의 차이점
13030정성태4/15/20226566오류 유형: 804. 정규 표현식 오류 - Quantifier {x,y} following nothing.
13029정성태4/14/20226976Windows: 203. iisreset 후에도 이전에 설정한 전역 환경 변수가 w3wp.exe에 적용되는 문제
13028정성태4/13/20226895.NET Framework: 1193. (appsettings.json처럼) web.config의 Debug/Release에 따른 설정 적용
13027정성태4/12/20227169.NET Framework: 1192. C# - 환경 변수의 변화를 알리는 WM_SETTINGCHANGE Win32 메시지 사용법파일 다운로드1
13026정성태4/11/20228714.NET Framework: 1191. C 언어로 작성된 FFmpeg Examples의 C# 포팅 전체 소스 코드 [3]
13025정성태4/11/20228077.NET Framework: 1190. C# - ffmpeg(FFmpeg.AutoGen)를 이용한 vaapi_encode.c, vaapi_transcode.c 예제 포팅
13024정성태4/7/20226577.NET Framework: 1189. C# - 런타임 환경에 따라 달라진 AppDomain.GetCurrentThreadId 메서드
13023정성태4/6/20226864.NET Framework: 1188. C# - ffmpeg(FFmpeg.AutoGen)를 이용한 transcoding.c 예제 포팅 [3]
13022정성태3/31/20226769Windows: 202. 윈도우 11 업그레이드 - "PC Health Check"를 통과했지만 여전히 업그레이드가 안 되는 경우 해결책
13021정성태3/31/20226963Windows: 201. Windows - INF 파일을 이용한 장치 제거 방법
13020정성태3/30/20226709.NET Framework: 1187. RDP 접속 시 WPF UserControl의 Unloaded 이벤트 발생파일 다운로드1
13019정성태3/30/20226684.NET Framework: 1186. Win32 Message를 Code로부터 메시지 이름 자체를 구하고 싶다면?파일 다운로드1
13018정성태3/29/20227219.NET Framework: 1185. C# - Unsafe.AsPointer가 반환한 포인터는 pinning 상태일까요? [5]
13017정성태3/28/20226979.NET Framework: 1184. C# - GC Heap에 위치한 참조 개체의 주소를 알아내는 방법 - 두 번째 이야기 [3]
13016정성태3/27/20227879.NET Framework: 1183. C# 11에 추가된 ref 필드의 (우회) 구현 방법파일 다운로드1
13015정성태3/26/20229202.NET Framework: 1182. C# 11 - ref struct에 ref 필드를 허용 [1]
13014정성태3/23/20227788VC++: 155. CComPtr/CComQIPtr과 Conformance mode 옵션의 충돌 [1]
13013정성태3/22/20226069개발 환경 구성: 641. WSL 우분투 인스턴스에 파이썬 2.7 개발 환경 구성하는 방법
13012정성태3/21/20225393오류 유형: 803. C# - Local '...' or its members cannot have their address taken and be used inside an anonymous method or lambda expression
... 16  17  18  19  20  21  22  23  [24]  25  26  27  28  29  30  ...