Microsoft MVP성태의 닷넷 이야기
개발 환경 구성: 254. SQL 서버 역시 SSL 3.0/TLS 1.0만을 지원하는 듯! [링크 복사], [링크+제목 복사]
조회: 18814
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 
(연관된 글이 2개 있습니다.)
(시리즈 글이 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




SQL 서버 역시 SSL 3.0/TLS 1.0만을 지원하는 듯!

지난 글에서 살펴본 것처럼,

System.Data.SqlClient는 SSL 3.0/TLS 1.0만 지원하는 듯!
; https://www.sysnet.pe.kr/2/0/1833

클라이언트가 이미 TLS 1.1/1.2를 지원하지 않고 있기 때문에 서버에서의 설정은 사실 무의미합니다. 그래도 한번 현상을 재현이나 해볼까요? ^^

우선, SQL 서버 측에 보안 통신을 위한 인증서를 등록해 보겠습니다.

"시작" / "Microsoft SQL Server 2008 R2" / "Configuration Tools" / "SQL Server Configuration Manager"를 실행하고 "SQL Server Network Configuration" / "Protocols for [YOUR_SQL_SERVER_INSTANCE]" 노드를 선택하고 마우스 우클릭을 해 "Properties" 메뉴를 선택해 다음의 설정을 해줍니다.

"Flags" 탭
  - "Force Encryption" 옵션을 Yes로 설정

"Certificate"
  - "Certiciate" 목록 상자에서 원하는 인증서를 선택

그런데, 받아 두었던 인증서가 "Certificate" 항목에 나타나지 않는 경우도 있습니다. 왜냐하면, 여기에 인증서가 나타나려면 2가지 조건을 만족해야 하기 때문입니다. (참조: Enabling Certificate for SSL on a SQL Server 2005 Clustered Installation)

  1. Certificates (Local Computer) 영역의 "Personal" 폴더에 위치
  2. 컴퓨터의 FQDN 이름과 일치하는 인증서(AD 참여 서버의 경우 도메인 이름까지 명시)

다행히 "Certificate" 목록 상자에 나오지 않아도 레지스트리를 통한 수작업 설정 방법이 제공되고 있으니 걱정하지 않아도 됩니다. 다음의 글에 따라,

Enabling Certificate for SSL on a SQL Server 2005 Clustered Installation
; http://blogs.msdn.com/b/jorgepc/archive/2008/02/19/enabling-certificates-for-ssl-connection-on-sql-server-2005-clustered-installation.aspx

Setting up SSL encryption for SQL Server using certificates ? Issues, tips & tricks
; http://thesqldude.com/2012/04/21/setting-up-ssl-encryption-for-sql-server-using-certificates-issues-tips-tricks/

"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQLServer\SuperSocketNetLib" 레지스트리 경로에 해당 인증서의 "Thumbprint" 값을 직접 입력하면 됩니다.

Name: Certificate
Type: REG_SZ
Data: ...[Your Certificate's Thumbprint]... (예: 1e385500fc7415f7843d83796b36b83450758c9e)

Thumbprint 값은 인증서 관리 콘솔에서 해당 인증서의 속성 창을 통해 구할 수 있는데, "공백 문자"가 포함되어 있기 때문에 메모장 등을 이용해 공백을 제거한 후 레지스트리에 설정해야 합니다.

결국, 다음의 2가지 처리를 해주시면 SQL 서버는 보안 통신을 할 수 있게 됩니다.

  1. "Force Encryption" 옵션을 Yes로 설정
  2. ...\SuperSocketNetLib 레지스트리 키의 "Certificate" 값에 인증서의 Thumbprint 값 입력

이 외에 주의 사항으로 해당 인증서의 개인 키 파일에 대해 SQL Server 프로세스의 실행 계정이 접근 가능해야 한다는 것입니다. 예를 들어, 제 경우에 SQL Server를 "Network Service" 계정으로 구동하는데 이로 인해 다음과 같이 (인증서 우클릭, "All Tasks" / "Manage Private Keys..." 메뉴 선택) 인증서의 개인키에 대한 접근 권한에 "Read"를 부여해야 합니다.

tls12_sql_1.png

모든 것이 정상적으로 설정되었다면 이제 SQL Service를 재시작합니다. 정상적으로 설정한 경우, 이벤트 로그에 "Event ID == 26013"으로 다음과 같은 항목을 볼 수 있습니다.

Log Name:      Application
Source:        MSSQLSERVER
Date:          2015-01-03 오후 4:33:09
Event ID:      26013
Task Category: Server
Level:         Information
Keywords:      Classic
User:          N/A
Computer:      win2008r2.testad.com
Description:
The certificate [Cert Hash(sha1) "1CB297B8F148FB061E43B3A09D0C524B75151457"] was successfully loaded for encryption.




자, 그럼 이제 TLS 제약을 좀 해볼까요? ^^

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 2.0]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 2.0\Client]
"DisabledByDefault"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 2.0\Server]
"Enabled"=dword:00000000
"DisabledByDefault"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 3.0]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 3.0\Client]
"DisabledByDefault"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 3.0\Server]
"Enabled"=dword:00000000
"DisabledByDefault"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Client]
"DisabledByDefault"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Server]
"Enabled"=dword:00000000
"DisabledByDefault"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Client]
"DisabledByDefault"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Server]
"Enabled"=dword:00000000
"DisabledByDefault"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client]
"DisabledByDefault"=dword:00000000
"Enabled"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Server]
"Enabled"=dword:00000001
"DisabledByDefault"=dword:00000000

위의 레지스트리 등록은 SSL 2.0/3.0, TLS 1.0/1.1을 비활성화하고 TLS 1.2만을 활성화시킵니다. 이렇게 하고 SQL 서비스를 재시작하면 이제 Event ID == 17182, 26014 등의 오류 항목이 이벤트 로그에 남는 것을 보게 됩니다.

Log Name:      Application
Source:        MSSQLSERVER
Date:          2015-01-03 오전 7:55:44
Event ID:      17182
Task Category: Server
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      win2008r2.testad.com
Description:
TDSSNIClient initialization failed with error 0x80092004, status code 0x80. Reason: Unable to initialize SSL support. Cannot find object or property.

Log Name:      Application
Source:        MSSQLSERVER
Date:          2015-01-03 오전 7:55:44
Event ID:      26014
Task Category: Server
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      win2008r2.testad.com
Description:
Unable to load user-specified certificate [Cert Hash(sha1) "1E385500FC7415F7843D83796B36B83450758C9E"]. The server will not accept a connection. You should verify that the certificate is correctly installed. See "Configuring Certificate for Use by SSL" in Books Online

이 상태에서 SSL 3.0이나,

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 3.0]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 3.0\Server]
"Enabled"=dword:00000001

TLS 1.0에 대해,

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Server]
"Enabled"=dword:00000001

둘 중의 하나라도 Server 레지스트리 키를 Enabled == 1로 설정하면 다시 SQL Server는 정상적으로 서비스가 됩니다.




어찌 보면, 자연스러운 것이 아닐까 생각됩니다. 클라이언트 측에서 SSL 3.0/TLS 1.0만을 사용해 접속하는 데 SQL 서버 측에서 그 프로토콜들을 모두 막아버리면 통신할 방법이 없으니까요.

검색을 해보니, 누군가도 TLS 1.0, SSL 3.0 관련한 문제를 결국 그 중 하나를 살려두는 것으로 해결(?)했다고 합니다.

Sql server service wont start after disabling TLS 1.0 and SSL 3.0 on windows
; http://answers.flyppdevportal.com/categories/sqlserver/sqlsecurity.aspx?ID=5f543d1f-9483-49bb-9c65-999f287eaefa

여기서 문제는? IIS 서버와 SQL 서버를 함께 설치한 경우입니다. IIS 서버를 위해 TLS 1.2 강제 설정을 했는데, 그것이 SQL 서버까지 영향을 미친 것입니다.

제가 몇몇 조합을 해보니, 이런 경우는 TLS 1.0은 살려두면서 "DisableByDefault" 설정을 1로 해두면 IIS의 TLS 1.2 접속은 강제하면서 SQL 서버는 정상적으로 TLS 1.0 서비스를 했습니다.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Client]
"DisabledByDefault"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Server]
"Enabled"=dword:00000001
"DisabledByDefault"=dword:00000001

아쉽게도 DisabledByDefault 옵션에 대해 Microsoft의 공식 문서가 없어서 정확히 어떤 차이점으로 인해 그렇게 되는지는 알 수 없었습니다.

마지막으로, 테스트를 하다 보니 Client 역할에 대해서도 제법 많은 서비스들이 TLS 1.2만 강제한 경우 문제가 발생했습니다. 따라서, 기존 서비스들에 영향을 최소화하면서 IIS TLS 1.2 강제를 위해 다음과 같은 정도로 레지스트리 구성을 하면 좋을 것 같습니다.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 2.0]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 2.0\Client]
"DisabledByDefault"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 2.0\Server]
"Enabled"=dword:00000000
"DisabledByDefault"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 3.0]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 3.0\Server]
"Enabled"=dword:00000001
"DisabledByDefault"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Server]
"Enabled"=dword:00000001
"DisabledByDefault"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Server]
"Enabled"=dword:00000001
"DisabledByDefault"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2]

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Server]
"Enabled"=dword:00000001
"DisabledByDefault"=dword:00000000

그런데, 아직도 의아스러운 점이 있다면? 마이크로소프트 직원에 의하면,

SSL Cipher Suites used with SQL Server
; https://techcommunity.microsoft.com/t5/sql-server-blog/ssl-cipher-suites-used-with-sql-server/ba-p/383303

"
What the best cipher suite to use is negotiated by SSL/TLS and depends upon the cipher suites supported by the OS on the client and the server
...[생략]...
Determine the highest level protocol mutually supported by the client and the server.
The currently recognised protocols are, from highest to lowest: TLS1.1, TLS1.0, SSL3.0, SSL2.0
"


라고 하는 것으로 봐서 SQL Server/Client 레벨에서가 아닌 운영체제 지원 여부에 따라 TLS/SSL을 자유롭게 선택할 수 있는 듯 싶은데, 왜 SQL 서버가 SSL 3.0/TLS 1.0을 막았을 때 서비스가 안되는 것인지... 그 부분은 여전히 설명이 안되는 것 같습니다.




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

[연관 글]






[최초 등록일: ]
[최종 수정일: 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)
13576정성태3/8/20241543닷넷: 2228. .NET Profiler - IMetaDataEmit2::DefineMethodSpec 사용법
13575정성태3/7/20241676닷넷: 2227. 최신 C# 문법을 .NET Framework 프로젝트에 쓸 수 있을까요?
13574정성태3/6/20241557닷넷: 2226. C# - "Docker Desktop for Windows" Container 환경에서의 IPv6 DualMode 소켓
13573정성태3/5/20241563닷넷: 2225. Windbg - dumasync로 분석하는 async/await 호출
13572정성태3/4/20241641닷넷: 2224. C# - WPF의 Dispatcher Queue로 알아보는 await 호출의 hang 현상파일 다운로드1
13571정성태3/1/20241618닷넷: 2223. C# - await 호출과 WPF의 Dispatcher Queue 동작 확인파일 다운로드1
13570정성태2/29/20241631닷넷: 2222. C# - WPF의 Dispatcher Queue 동작 확인파일 다운로드1
13569정성태2/28/20241545닷넷: 2221. C# - LoadContext, LoadFromContext 그리고 GAC파일 다운로드1
13568정성태2/27/20241606닷넷: 2220. C# - .NET Framework 프로세스의 LoaderOptimization 설정을 확인하는 방법파일 다운로드1
13567정성태2/27/20241617오류 유형: 898. .NET Framework 3.5 이하에서 mscoree.tlb 참조 시 System.BadImageFormatException파일 다운로드1
13566정성태2/27/20241630오류 유형: 897. Windows 7 SDK 설치 시 ".NET Development" 옵션이 비활성으로 선택이 안 되는 경우
13565정성태2/23/20241478닷넷: 2219. .NET CLR2 보안 모델에서의 개별 System.Security.Permissions 제어
13564정성태2/22/20241614Windows: 259. Hyper-V Generation 1 유형의 VM을 Generation 2 유형으로 바꾸는 방법
13563정성태2/21/20241644디버깅 기술: 196. windbg - async/await 비동기인 경우 메모리 덤프 분석의 어려움
13562정성태2/21/20241644오류 유형: 896. ASP.NET - .NET Framework 기본 예제에서 System.Web에 대한 System.IO.FileNotFoundException 예외 발생
13561정성태2/20/20241742닷넷: 2218. C# - (예를 들어, Socket) 비동기 I/O에 대한 await 호출 시 CancellationToken을 이용한 취소파일 다운로드1
13560정성태2/19/20241746디버깅 기술: 195. windbg 분석 사례 - Semaphore 잠금으로 인한 Hang 현상 (닷넷)
13559정성태2/19/20242623오류 유형: 895. ASP.NET - System.Security.SecurityException: 'Requested registry access is not allowed.'
13558정성태2/18/20241819닷넷: 2217. C# - 최댓값이 1인 SemaphoreSlim 보다 Mutex 또는 lock(obj)를 선택하는 것이 나은 이유
13557정성태2/18/20241619Windows: 258. Task Scheduler의 Author 속성 값을 변경하는 방법
13556정성태2/17/20241684Windows: 257. Windows - Symbolic (hard/soft) Link 및 Junction 차이점
13555정성태2/15/20241952닷넷: 2216. C# - SemaphoreSlim 사용 시 주의점
13554정성태2/15/20241708VS.NET IDE: 189. Visual Studio - 닷넷 소스코드 디컴파일 찾기가 안 될 때
13553정성태2/14/20241735닷넷: 2215. windbg - thin/fat lock 없이 동작하는 Monitor.Wait + Pulse
13552정성태2/13/20241685닷넷: 2214. windbg - Monitor.Enter의 thin lock과 fat lock
13551정성태2/12/20242016닷넷: 2213. ASP.NET/Core 웹 응용 프로그램 - 2차 스레드의 예외로 인한 비정상 종료
1  [2]  3  4  5  6  7  8  9  10  11  12  13  14  15  ...