Skip to content

Use jarsigner to verify reproducible APKs

This branch uses jarsigner to verify reproducible APKs, to avoid nondeterministic failures caused by jarsigner or apksigner being used depending on which APKs the build server has previously built.

Reprodubible builds for Briar have been failing since the signing branch was merged two weeks ago (akwizgran/fdroidserver@06766ba4). This is because the behaviour of verify_apk_signature() now depends on on whether sign_apk() has previously been called on the same build server instance. sign_apk() calls find_apksigner(), which may find a copy of apksigner that isn't on the PATH and add that copy to the config object, where verify_apk_signature() subsequently finds it.

The result is that if the build server signs a non-reproducible APK before trying to verify a reproducible APK, and if apksigner isn't on the PATH but is found in the Android SDK, then the verification of the reproducible APK will use apksigner, whereas if the build server tries to verify the same reproducible APK before signing any non-reproducible APKs, the verification will use jarsigner.

If the reproducible APK has v1 and v2 signatures (as Briar does) then verification of the rebuilt APK with apksigner will fail due to the missing v2 signature, whereas verification with jarsigner will succeed because it only checks the v1 signature.

This MR fixes the nondeterminism by always using jarsigner. It should be considered a stopgap until verification of v2 signatures is implemented (!802 (closed)).

Another option would be to call find_apksigner() from verify_apk_signature(), thus fixing the nondeterminism by always using apksigner if available, and then pass --max-sdk-version=23 to apksigner so it doesn't complain about the missing v2 signature. The --max-sdk-version argument could then be removed when verification of v2 signatures is implemented.

Closes #697 (closed)

Merge request reports