콘텐츠로 이동

서명과 공증

모든 플랫폼의 패키지에 서명하고, Windows 다운로드에 Authenticode로 서명하고, Mac 앱을 공증합니다.

sign:
identity: "Apple Development: you@example.com (ABCDE12345)" # signs the macOS app, else ad hoc
profile: assets/AppStore.mobileprovision # signs the IPA
keystore: assets/release.p12 # signs APKs, with key_alias
certificate: assets/codesign.pfx # signs the Windows app and its installer
# widgets_profile: assets/Widgets.mobileprovision # the iOS extension's profile; use a macOS profile for a Mac App Store build
# share_profile: assets/Share.mobileprovision # signs the IPA's share extension
# clip_profile: assets/Clip.mobileprovision # signs the IPA's App Clip

키스토어의 비밀번호는 NSGO_KEYSTORE_PASSWORD와 NSGO_KEY_PASSWORD에서 읽어옵니다. -team은 iPhone 패키지에 서명합니다. -profile, -widgets-profile, -share-profile, -clip-profile, -macos-profile은 커맨드라인에서 앱, 위젯 확장, 공유 확장, App Clip, Mac App Store 프로비저닝 프로필을 각각 대체합니다. -installer는 Mac Installer Distribution 인증서를 대체합니다.

Authenticode는 Windows 다운로드의 게시자를 식별합니다(SmartScreen 평판 검사는 별개입니다). .pfx 파일인 sign.certificate는 실행 파일, 커맨드 동반 파일, 앱 리소스에 포함된 프로그램과 라이브러리, 언인스톨러가 포함된 인스톨러, 스토어 채널용으로 빌드된 MSIX에 서명하며 비밀번호는 NSGO_CERTIFICATE_PASSWORD에서 가져옵니다. 서명은 signtool과 동일한 방식으로 Go에서 직접 생성되므로 Windows SDK 없이 Mac에서도 서명할 수 있습니다:

sign:
certificate: assets/codesign.pfx
timestamp_url: http://timestamp.digicert.com # the RFC 3161 server that timestamps them

sign.timestamp_url의 기본값은 DigiCert 서버이며, none을 주면 타임스탬프 없이 서명되어 인증서 만료 시 서명 효력도 만료됩니다. 하드웨어 토큰이나 클라우드 서비스에 있는 인증서는 대신 %1이 서명 대상 파일 경로를 뜻하는 자체 명령을 통해 서명할 수 있으며 빌드가 위의 모든 파일에 대해 이 명령을 실행합니다:

sign:
sign_command: "signtool sign /fd sha256 /tr http://timestamp.digicert.com /td sha256 /a %1"

명령이 성공하더라도 앱 실행 파일, 커맨드 동반 파일, PE 리소스 또는 셋업 실행 파일 중 하나라도 내장된 Authenticode 서명이 빠져 있으면 build는 중단됩니다.

인스톨러 내부의 언인스톨러는 내장되기 전에 앱 및 셋업과 같은 sign.certificate 또는 sign.sign_command로 서명됩니다. -certificate, -sign-command, -timestamp-url로 커맨드라인에서 이를 설정할 수 있습니다.

Mac에서 다운로드한 앱은 Apple의 공증(notarization)을 받으면 Gatekeeper 경고 없이 열립니다. Developer ID로 서명하고 notarytool이 키체인에 저장한 자격 증명 이름을 지정하세요:

xcrun notarytool store-credentials hello --apple-id you@example.com --team-id ABCDE12345
sign:
identity: "Developer ID Application: Example Inc (ABCDE12345)"
notarize: hello # the keychain profile above; or -notarize hello

그러면 build는 강화된 런타임으로 서명하고 디스크 이미지를 제출한 뒤 몇 분간 Apple의 판정을 기다려 이미지와 앱에 티켓을 스테이플링하며, 거부되면 Apple의 로그를 출력합니다. CI에서는 App Store Connect API 키의 .p8 파일, ID, 발급자인 NSGO_NOTARY_KEY, NSGO_NOTARY_KEY_ID, NSGO_NOTARY_ISSUER가 키체인 프로필을 대신합니다. 강화된 런타임은 앱이 권한을 선언하지 않으면 마이크, 카메라, 캘린더, 위치 접근을 차단하는데, apple.info에 NSMicrophoneUsageDescription, NSCameraUsageDescription, 캘린더/미리알림 사용 설명, 위치 사용 설명이 들어 있으면 build가 해당 권한을 자동으로 추가합니다.