Add code signing of release binaries via cargo-code-sign#18280
Add code signing of release binaries via cargo-code-sign#18280
cargo-code-sign#18280Conversation
d64d72a to
5cacad5
Compare
1104b91 to
5810e1c
Compare
9db7448 to
6e33a04
Compare
5810e1c to
921eac1
Compare
49125e3 to
355fe05
Compare
e91fbc7 to
6ea7974
Compare
6ea7974 to
b7dd415
Compare
| openssl req -x509 -newkey rsa:2048 -sha256 -days 7 -nodes \ | ||
| -keyout "$CERT_DIR/key.pem" \ | ||
| -out "$CERT_DIR/cert.pem" \ | ||
| -subj "/CN=$CERT_NAME" \ | ||
| -addext "extendedKeyUsage=codeSigning" \ | ||
| -addext "keyUsage=digitalSignature" |
There was a problem hiding this comment.
I think there are additional Apple-specific X.509 extensions we need to include here, in order for the self-signed cert to look "right" to Apple's codesigning machinery.
Ref: https://docs.rs/apple-codesign/0.29.0/src/apple_codesign/certificate.rs.html#1276-1286
(Maybe it makes sense to use rcodesign to bootstrap the testing cert here?)
There was a problem hiding this comment.
Note this will also inherit from the host openssl.conf (if it exists) and may alter the output in some cases. Normally when I have done this I tend to pass the entire config via stdin to avoid such cases with scripts invoking openssl e.g.
openssl req -x509 -newkey rsa:2048 -sha256 -days 7 -nodes \
-keyout "$CERT_DIR/key.pem" \
-out "$CERT_DIR/cert.pem" \
-config <(
cat <<-EOF
[req]
prompt = no
distinguished_name = dn
x509_extensions = ext
[dn]
O = Astral Software Inc.
CN = $CERT_NAME
[ext]
keyUsage = digitalSignature
extendedKeyUsage = codeSigning
EOF
)Inspired by #18252 This required an upstream change rust-secure-code/cargo-auditable#245 which is now released. This increases binary sizes slightly, ~4KB. The cargo wrapper implementation will be extended in #18280 to code sign binaries.
Instead of generating test secrets in the workflow itself as was done in #18280 for testing. This includes a script to generate self-signed certificates and adds them to the `release-test` environment. We'll populate the real secrets in the `release` environment. We may want a dedicated environment for code-signing secrets? We also may want to sign with the real secrets on `main` or similar.
Instead of generating test secrets in the workflow itself as was done in #18280 for testing. This includes a script to generate self-signed certificates and adds them to the `release-test` environment. We'll populate the real secrets in the `release` environment. We may want a dedicated environment for code-signing secrets? We also may want to sign with the real secrets on `main` or similar.
971341a to
7cfc0b7
Compare
| ## Secrets: CODESIGN_CERTIFICATE_PASSWORD, CODESIGN_IDENTITY_MACOS, | ||
| ## CODESIGN_CERTIFICATE_MACOS, CODESIGN_CERTIFICATE_WINDOWS | ||
| ## Variables: CODESIGN_ALLOW_UNTRUSTED_MACOS |
There was a problem hiding this comment.
Enumerate these in a bullet point list, we don't need to differentiate between secrets / variables in this doc
Adds code signing of our release binaries on Windows and macOS, using temporary self-signed certificates for testing.
Instead of signing via
uv buildas explored in #18262, we use a cargo extension to sign on build. This allows us to sign both the artifacts inside and outside of wheels without changing maturin. This builds on patterns introduced in #18276.I built
cargo-code-signas a standalone tool, heavily referencing existing code signing techniques in the ecosystem, see https://github.com/zanieb/code-sign-toolsIncludes #18295
This does not configure secrets for the actual release environment yet.