Microsoft MVP성태의 닷넷 이야기
개발 환경 구성: 254. SQL 서버 역시 SSL 3.0/TLS 1.0만을 지원하는 듯! [링크 복사], [링크+제목 복사]
조회: 18889
글쓴 사람
정성태 (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)
13533정성태1/18/20242450닷넷: 2206. C# - TCP KeepAlive의 서버 측 구현파일 다운로드1
13532정성태1/17/20242345닷넷: 2205. C# - SuperSimpleTcp 사용 시 주의할 점파일 다운로드1
13531정성태1/16/20242235닷넷: 2204. C# - TCP KeepAlive에 새로 추가된 Retry 옵션파일 다운로드1
13530정성태1/15/20242190닷넷: 2203. C# - Python과의 AES 암호화 연동파일 다운로드1
13529정성태1/15/20242051닷넷: 2202. C# - PublishAot의 glibc에 대한 정적 링킹하는 방법
13528정성태1/14/20242178Linux: 68. busybox 컨테이너에서 실행 가능한 C++, Go 프로그램 빌드
13527정성태1/14/20242107오류 유형: 892. Visual Studio - Failed to launch debug adapter. Additional information may be available in the output window.
13526정성태1/14/20242204닷넷: 2201. C# - Facebook 연동 / 사용자 탈퇴 처리 방법
13525정성태1/13/20242158오류 유형: 891. Visual Studio - Web Application을 실행하지 못하는 IISExpress
13524정성태1/12/20242220오류 유형: 890. 한국투자증권 KIS Developers OpenAPI - GW라우팅 중 오류가 발생했습니다.
13523정성태1/12/20242028오류 유형: 889. Visual Studio - error : A project with that name is already opened in the solution.
13522정성태1/11/20242190닷넷: 2200. C# - HttpClient.PostAsJsonAsync 호출 시 "Transfer-Encoding: chunked" 대신 "Content-Length" 헤더 처리
13521정성태1/11/20242256닷넷: 2199. C# - 한국투자증권 KIS Developers OpenAPI의 WebSocket Ping, Pong 처리
13520정성태1/10/20242001오류 유형: 888. C# - Unable to resolve service for type 'Microsoft.Extensions.ObjectPool.ObjectPool`....'
13519정성태1/10/20242093닷넷: 2198. C# - Reflection을 이용한 ClientWebSocket의 Ping 호출파일 다운로드1
13518정성태1/9/20242353닷넷: 2197. C# - ClientWebSocket의 Ping, Pong 처리
13517정성태1/8/20242198스크립트: 63. Python - 공개 패키지를 이용한 위성 이미지 생성 (pystac_client, odc.stac)
13516정성태1/7/20242304닷넷: 2196. IIS - AppPool의 "Disable Overlapped Recycle" 옵션의 부작용
13515정성태1/6/20242582닷넷: 2195. async 메서드 내에서 C# 7의 discard 구문 활용 사례 [1]
13514정성태1/5/20242255개발 환경 구성: 702. IIS - AppPool의 "Disable Overlapped Recycle" 옵션
13513정성태1/5/20242176닷넷: 2194. C# - WebActivatorEx / System.Web의 PreApplicationStartMethod 특성
13512정성태1/4/20242143개발 환경 구성: 701. IIS - w3wp.exe 프로세스의 ASP.NET 런타임을 항상 Warmup 모드로 유지하는 preload Enabled 설정
13511정성태1/4/20242162닷넷: 2193. C# - ASP.NET Web Application + OpenAPI(Swashbuckle) 스펙 제공
13510정성태1/3/20242099닷넷: 2192. C# - 특정 실행 파일이 있는지 확인하는 방법 (Linux)
13509정성태1/3/20242122오류 유형: 887. .NET Core 2 이하의 프로젝트에서 System.Runtime.CompilerServices.Unsafe doesn't support netcoreapp2.0.
13508정성태1/3/20242141오류 유형: 886. ORA-28000: the account is locked
1  2  3  [4]  5  6  7  8  9  10  11  12  13  14  15  ...