코드 서명(Code Signing)은 소프트웨어 배포 시 개발자의 디지털 서명을 첨부해 무결성과 출처를 보증하는 기술이다. 공급망 보안의 핵심 요소다.
코드 서명 동작 방식
[개발자]
코드 → SHA-256 해시 생성
해시 → 개인키로 서명 (RSA/ECDSA)
서명 + 공개키 인증서 → 배포 파일에 첨부
[사용자/시스템]
서명 추출 → CA 인증서로 검증
파일 해시 재계산 → 서명의 해시와 비교
일치 → 신뢰, 불일치 → 경고/차단
플랫폼별 코드 서명
| 플랫폼 | 도구 | 인증서 발급처 |
|---|
| Windows | signtool.exe | DigiCert, Sectigo (EV OV) |
| macOS/iOS | codesign, Xcode | Apple Developer Program |
| Android | apksigner, jarsigner | 자체 서명 or Google Play |
| Linux (.deb) | dpkg-sig | Debian/배포판 키링 |
| Linux (RPM) | rpmsign | GPG 키 |
Windows 코드 서명
powershell
# 1. PFX 인증서 가져오기
$cert = Get-ChildItem Cert:CurrentUserMy -CodeSigningCert
# 2. 서명
Set-AuthenticodeSignature `
-FilePath ".\setup.exe" `
-Certificate $cert `
-TimestampServer "http://timestamp.digicert.com" `
-HashAlgorithm SHA256
# 3. 검증
Get-AuthenticodeSignature -FilePath ".setup.exe" | Format-List
# Status: Valid 확인
macOS 코드 서명
bash
# 앱 서명
codesign --sign "Developer ID Application: My Company (TEAM_ID)" --options runtime --entitlements entitlements.plist --timestamp MyApp.app
# 공증(Notarization) - macOS Gatekeeper 통과
xcrun notarytool submit MyApp.zip --apple-id "dev@example.com" --team-id "TEAM_ID" --password "@keychain:AC_PASSWORD" --wait
# 스테이플링 (공증 티켓 첨부)
xcrun stapler staple MyApp.app
Sigstore (오픈소스 서명 인프라)
bash
# cosign으로 컨테이너 이미지 서명
cosign sign --key cosign.key gcr.io/myapp:v1.0
# 검증
cosign verify --key cosign.pub gcr.io/myapp:v1.0
# Keyless 서명 (OIDC + 투명성 로그)
cosign sign gcr.io/myapp:v1.0
# OIDC 로그인 → Fulcio가 단기 인증서 발급 → Rekor에 기록
관련 문서