2 분 소요

사내 PKI(Public Key Infrastructure)를 구축하면 내부 웹 서비스, VPN, 무선 네트워크 인증 등에 신뢰된 인증서를 무료로 발급할 수 있습니다. Windows Server의 Active Directory 인증서 서비스(AD CS)로 이를 구현할 수 있습니다.

서버 보안 이미지

PKI 인프라로 보호되는 기업 네트워크 환경

PKI 계층 구조

Root CA (오프라인, 독립 서버)
    └── Subordinate CA (온라인, 발급 CA)
            ├── 웹 서버 인증서
            ├── 사용자 인증서
            └── 컴퓨터 인증서

보안 모범 사례는 Root CA를 오프라인 상태로 유지하고, Subordinate CA만 온라인으로 운영하는 것입니다.

AD CS 설치

# 인증서 서비스 역할 설치
Install-WindowsFeature AD-Certificate -IncludeManagementTools

# 웹 등록 인터페이스 추가 (선택)
Install-WindowsFeature ADCS-Web-Enrollment

# 온라인 응답자 추가 (OCSP, 선택)
Install-WindowsFeature ADCS-Online-Cert

# 설치 확인
Get-WindowsFeature -Name ADCS* | Where-Object Installed

Root CA 구성 (독립 CA)

# 독립(Standalone) Root CA 설치
Install-AdcsCertificationAuthority `
    -CAType StandaloneRootCA `
    -CACommonName "Company Root CA" `
    -KeyLength 4096 `
    -HashAlgorithmName SHA256 `
    -ValidityPeriod Years `
    -ValidityPeriodUnits 20 `
    -Force

# Root CA 인증서 내보내기
$cert = Get-ChildItem Cert:\LocalMachine\CA |
    Where-Object { $_.Subject -like "*Company Root CA*" }

Export-Certificate -Cert $cert `
    -FilePath "C:\RootCA\CompanyRootCA.cer"

Subordinate CA 구성

# 엔터프라이즈 Subordinate CA 설치 (도메인 가입 필요)
Install-AdcsCertificationAuthority `
    -CAType EnterpriseSubordinateCA `
    -CACommonName "Company Issuing CA" `
    -ParentCA "rootca.company.local\Company Root CA" `
    -KeyLength 2048 `
    -HashAlgorithmName SHA256 `
    -ValidityPeriod Years `
    -ValidityPeriodUnits 5 `
    -Force

# Root CA에서 CSR 서명 후 인증서 설치
# (Root CA에서 승인 후 진행)
Install-AdcsCertificationAuthority -Force

인증서 템플릿 설정

# 인증서 템플릿 목록 확인
certutil -template | Select-String "Template"

# 새 웹 서버 인증서 템플릿 생성
# (인증서 템플릿 MMC 스냅인에서 기존 "Web Server" 템플릿 복제)
# 또는 PowerShell PSPKI 모듈 사용
Install-Module -Name PSPKI -Force
Import-Module PSPKI

# 현재 템플릿 목록
Get-CertificateTemplate | Select-Object DisplayName, Name

인증서 발급

# 웹 서버 인증서 요청 생성
$san = "webserver.company.local", "www.company.local"
$cert = Get-Certificate `
    -Template "WebServer" `
    -SubjectName "CN=webserver.company.local" `
    -DnsName $san `
    -CertStoreLocation Cert:\LocalMachine\My `
    -Url ldap:

# 발급된 인증서 확인
Get-ChildItem Cert:\LocalMachine\My |
    Where-Object { $_.Subject -like "*company*" } |
    Select-Object Subject, Thumbprint, NotAfter
:: certreq.exe로 인증서 요청 (커맨드 프롬프트)
certreq -new request.inf request.csr
certreq -submit -config "caserver\Company Issuing CA" request.csr cert.cer
certreq -accept cert.cer

코드 화면 이미지

AD CS에서 인증서를 발급하는 관리 화면

루트 CA 인증서 배포

# 도메인 내 모든 컴퓨터에 Root CA 인증서 자동 배포
# (그룹 정책 > 공용 키 정책 > 신뢰할 수 있는 루트 인증 기관)

# 또는 PowerShell로 직접 가져오기
Import-Certificate `
    -FilePath "\\server\share\CompanyRootCA.cer" `
    -CertStoreLocation Cert:\LocalMachine\Root

# certutil 사용
certutil -addstore Root "C:\RootCA\CompanyRootCA.cer"

인증서 만료 모니터링

# 30일 내 만료되는 인증서 찾기
$threshold = (Get-Date).AddDays(30)

Get-ChildItem Cert:\LocalMachine\My |
    Where-Object { $_.NotAfter -lt $threshold -and $_.NotAfter -gt (Get-Date) } |
    Select-Object Subject, Thumbprint,
    @{N='DaysLeft'; E={($_.NotAfter - (Get-Date)).Days}},
    NotAfter |
    Sort-Object DaysLeft |
    Format-Table -AutoSize

# 이메일 알림 자동화
$expiring = Get-ChildItem Cert:\LocalMachine\My |
    Where-Object { $_.NotAfter -lt (Get-Date).AddDays(30) }

if ($expiring) {
    $body = $expiring | Format-Table Subject, NotAfter | Out-String
    Send-MailMessage `
        -To "admin@company.com" `
        -Subject "인증서 만료 경고" `
        -Body $body `
        -SmtpServer "smtp.company.com"
}

CRL(인증서 해지 목록) 관리

# CRL 발행
certutil -crl

# CRL 배포 포인트 확인
certutil -getreg CA\CRLPublicationURLs

# CDP(CRL 배포 포인트) 설정
certutil -setreg CA\CRLPublicationURLs `
    "1:C:\Windows\system32\CertSrv\CertEnroll\%3%8%9.crl\n" +
    "2:http://pki.company.local/CertEnroll/%3%8%9.crl\n" +
    "2:ldap:///CN=%7%8,CN=%2,CN=CDP,CN=Public Key Services,CN=Services,%6%10"

사내 CA 운영은 인증서 만료 관리와 CRL 배포가 중요합니다. Root CA는 물리적으로 격리하여 오프라인 상태로 보관하고, 발급 CA만 온라인으로 운영하는 2-tier 구조가 보안상 권장됩니다. 구축 후 정기적인 인증서 만료 모니터링 자동화를 반드시 설정하세요.

댓글남기기