← 가이드

IIS 보안 조치 가이드

Windows IIS에서 Schannel로 TLS 1.0, 1.1을 끄고 보안 헤더와 HTTPS 리다이렉트를 건다. Schannel 설정은 서버 전체에 걸린다.

작업 전 확인

어느 조치를 하든 여기서 시작한다. RDP로 접속해 관리자 권한 PowerShell을 연다.

버전을 확인한다.

Get-ItemProperty HKLM:\SOFTWARE\Microsoft\InetStp\ | Select-Object VersionString
[System.Environment]::OSVersion.Version    # Windows Server 버전

IIS의 TLS는 OS(Schannel) 전역 설정이다. 같은 서버의 다른 서비스(RDP, SQL 연결 등)도 영향을 받는다. TLS 1.3은 Windows Server 2022 이상에서만 지원된다.

사이트와 바인딩, 바인딩된 인증서를 확인한다.

Get-Website | Select-Object Name, State
Get-WebBinding -Protocol https | Select-Object bindingInformation, certificateHash

TLS 1.0, 1.1 끄기

Server 2019 이하에서는 Schannel 레지스트리를 고친다.

foreach ($v in "TLS 1.0","TLS 1.1") {
  $p = "HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\$v\Server"
  New-Item -Path $p -Force | Out-Null
  Set-ItemProperty -Path $p -Name Enabled -Value 0 -Type DWord   # 0 = Disabled
}

TLS 1.3에 대해 MS 공식 문서는 “Windows 11 및 Windows Server 2022부터 지원. 그 이전 버전에서 TLS 1.3 활성화는 안전한 구성이 아님”이라고 한다. Server 2019 이하에서는 1.2까지가 목표다.

보안 헤더

IIS 관리자에서 사이트 → HTTP 응답 헤더 → 추가로 넣거나, 사이트 루트 web.config에 적는다.

<configuration>
  <system.webServer>
    <httpProtocol>
      <customHeaders>
        <add name="Strict-Transport-Security" value="max-age=31536000; includeSubDomains" />
        <add name="X-Content-Type-Options" value="nosniff" />
        <add name="X-Frame-Options" value="SAMEORIGIN" />
        <add name="Referrer-Policy" value="strict-origin-when-cross-origin" />
      </customHeaders>
    </httpProtocol>
  </system.webServer>
</configuration>

web.config는 저장하는 즉시 적용된다. 재시작은 필요 없다.

HTTP → HTTPS 리다이렉트

URL Rewrite 모듈을 설치하고 web.config에 넣는다.

<rewrite>
  <rules>
    <rule name="https-redirect" stopProcessing="true">
      <match url="(.*)" />
      <conditions><add input="{HTTPS}" pattern="off" /></conditions>
      <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
    </rule>
  </rules>
</rewrite>

약한 키나 서명이면 인증서 교체

Apache와 IIS 인증서 교체 절차의 IIS 부분을 따른다. 저장소 임포트와 바인딩 교체, 2단계다.

신규 도메인 인증서 설치

발급과 파일 준비는 발급 공통 가이드에서 먼저 끝낸다. IIS에는 PFX가 필요하다.

먼저 저장소에 임포트한다.

$pw = Read-Host -AsSecureString
Import-PfxCertificate -FilePath .\새도메인.pfx -CertStoreLocation Cert:\LocalMachine\My -Password $pw

저장소는 Cert:\LocalMachine\My(컴퓨터 계정)가 맞다. CurrentUser에 넣으면 IIS가 못 본다.

그다음 사이트 바인딩을 추가한다. IIS 관리자에서는 사이트 → 바인딩 → 추가에서 https, 443, 호스트 이름 새도메인을 넣고 SNI 필요에 체크한 뒤 인증서를 고른다. PowerShell로는 이렇게 한다.

New-WebBinding -Name "사이트명" -Protocol https -Port 443 -HostHeader "새도메인" -SslFlags 1
$cert = Get-ChildItem Cert:\LocalMachine\My | Where-Object Subject -match "새도메인"
(Get-WebBinding -Name "사이트명" -Protocol https -HostHeader "새도메인").AddSslCertificate($cert.Thumbprint, "My")

바인딩 추가는 재시작 없이 바로 적용된다.

진단 툴로 확인한다. PFX에 체인이 빠져 있으면 체인 오류가 난다. 교체 절차 글의 IIS 부분을 참고한다.

재검사

진단 툴로 다시 검사한다. 결과는 최대 10분 캐시된다.

공식 문서