What are code signing best practices?
Protect private keys in certified hardware. Control and log who can sign. Sign inside a controlled build process. Timestamp every signature. Scan before you sign. Have a plan to revoke and re-sign if a key or release is compromised.
- Keep keys in certified hardware. This has been required for publicly trusted certificates since June 1, 2023, and it’s good practice for private keys, too.
- Never share keys. Use role-based access and multi-factor authentication. Separate key administrators from signers, and remove access promptly when people change roles. (Why private keys should not be shared)
- Separate test keys from release keys. Use different keys for development builds and production releases.
- Sign in the pipeline, not on workstations. Automated, policy-controlled signing removes ad hoc signing. Hash signing keeps files local.
- Scan before signing. Signing malware makes it look trustworthy. Scan builds and dependencies first. Comparing builds from independent build servers can reveal tampering in the build process.
- Timestamp every signature. This keeps signatures valid after the certificate expires, and it limits the impact of revocation.
- Log and review signing activity. Record who or what signed, with which key, when, and under which policy.
- Plan for renewals. Public certificates now last at most 460 days.
- Enforce current cryptographic standards. Block weak algorithms and key sizes. RSA keys for public code signing must be at least 3072 bits. Track post-quantum guidance.
- Have an incident plan. If a key is compromised or malware is signed, contact your CA immediately to revoke the certificate. Then re-sign affected releases with a new key. Depending on the revocation date the CA sets, signatures timestamped before the compromise can remain valid.