Skip to content

fix: support signing unsigned Mach-O binaries without LC_CODE_SIGNATURE#44

Merged
nichmor merged 1 commit intonichmor:mainfrom
messense:codesign-macho-without-sign
Apr 7, 2026
Merged

fix: support signing unsigned Mach-O binaries without LC_CODE_SIGNATURE#44
nichmor merged 1 commit intonichmor:mainfrom
messense:codesign-macho-without-sign

Conversation

@messense
Copy link
Copy Markdown
Contributor

@messense messense commented Apr 2, 2026

Add support for ad-hoc signing Mach-O binaries that don't have an existing LC_CODE_SIGNATURE load command (unsigned binaries).

Changes:

  • Add write_u32/write_u64 helpers that respect binary endianness (ctx.le) instead of hardcoded .to_le_bytes()
  • Extract InsertCodeSigParams struct and insert_code_signature_command_into_buffer() as shared helper for inserting LC_CODE_SIGNATURE into header padding
  • Update generate_adhoc_signature() to parse binary context for endianness
  • Update adhoc_sign() to detect missing LC_CODE_SIGNATURE and insert it
  • Update adhoc_sign_file() to use shared helper for LC_CODE_SIGNATURE insertion

This is for PyO3/maturin#3114 (https://github.com/PyO3/maturin/actions/runs/23901410353/job/69698993401)

Comment thread crates/arwen-codesign/src/lib.rs Outdated
@messense messense force-pushed the codesign-macho-without-sign branch from 0aa7970 to 6cda6ea Compare April 7, 2026 12:20
Add support for ad-hoc signing Mach-O binaries that don't have an existing
LC_CODE_SIGNATURE load command (unsigned binaries).

Changes:
- Add write_u32/write_u64 helpers that respect binary endianness (ctx.le)
  instead of hardcoded .to_le_bytes()
- Extract InsertCodeSigParams struct and insert_code_signature_command_into_buffer()
  as shared helper for inserting LC_CODE_SIGNATURE into header padding
- Update generate_adhoc_signature() to parse binary context for endianness
- Update adhoc_sign() to detect missing LC_CODE_SIGNATURE and insert it
- Update adhoc_sign_file() to use shared helper for LC_CODE_SIGNATURE insertion
- Add test_sign_unsigned_binary test case
@messense messense force-pushed the codesign-macho-without-sign branch from 6cda6ea to 256194f Compare April 7, 2026 12:21
@nichmor nichmor merged commit 696351a into nichmor:main Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants