Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Android build should fail with incorrect keystore alias #655

Closed
DanielGrech opened this issue Feb 14, 2016 · 2 comments
Closed

Android build should fail with incorrect keystore alias #655

DanielGrech opened this issue Feb 14, 2016 · 2 comments

Comments

@DanielGrech
Copy link
Contributor

Trying to build a project with a keystore as such:

Pertinent BUCK file contents:

/** 
    release.keystore.properties contents:

    key.alias=some_incorrect_alias
    key.store.password=password1
    key.alias.password=password1
*/

keystore(
    name = 'release',
    store = 'release.keystore',
    properties = 'release.keystore.properties',
    visibility = ['PUBLIC']
)

android_binary(
    name = 'myapp_release',
    manifest = ':release-manifest',
    keystore = '//keystore:release',
    package_type = 'release',
    deps = [
      ':main-lib'
    ]
)

The file release.keystore.properties has an incorrect alias listed. I expect that the buck build myapp_release command should fail if the alias is incorrect. Instead, it fails silently and the resulting APK is not signed.

Validated with the command:

jarsigner -verify -verbose -certs buck-out/gen/myapp_release.apk

  s = signature was verified 
  m = entry is listed in manifest
  k = at least one certificate was found in keystore
  i = at least one certificate was found in identity scope

no manifest.
jar is unsigned. (signatures missing or not parsable)
@mkosiba
Copy link
Contributor

mkosiba commented Feb 18, 2016

Had a quick look. ApkBuilderStep, line 189-ish. If you add a null check on the key returned from keystore.getKey (Preconditions.checkNotNull or just call key.getFormat() or something) will it blow up?

@sean-kenny
Copy link
Contributor

@DanielGrech @marcinkosiba I verified that the values for Key and Certificate could be null if an invalid alias is provided, and added null pointer checks. When the checks are in place and in invalid alias is provided I see (instead of silent failure):

BUILD FAILED: //app:app failed on step apk_builder with an exception:
The keystore [/Users/seank/repo/spotify/buck-tests/BuckScenarioLibraryResourceMerging/app/debug.keystore] key.alias [androiddebugkeyasdfadsfs] does not exist or does not identify a key-related entry
java.lang.NullPointerException: The keystore [/Users/seank/repo/spotify/buck-tests/BuckScenarioLibraryResourceMerging/app/debug.keystore] key.alias [androiddebugkeyasdfadsfs] does not exist or does not identify a key-related entry
    at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:251)
    at com.facebook.buck.android.ApkBuilderStep.createKeystoreProperties(ApkBuilderStep.java:191)
    at com.facebook.buck.android.ApkBuilderStep.execute(ApkBuilderStep.java:122)
    at com.facebook.buck.step.DefaultStepRunner.runStepForBuildTarget(DefaultStepRunner.java:63)
    at com.facebook.buck.rules.CachingBuildEngine.executeCommandsNowThatDepsAreBuilt(CachingBuildEngine.java:1069)
    at com.facebook.buck.rules.CachingBuildEngine.access$10(CachingBuildEngine.java:1052)
    at com.facebook.buck.rules.CachingBuildEngine$4.apply(CachingBuildEngine.java:460)
    at com.facebook.buck.rules.CachingBuildEngine$4.apply(CachingBuildEngine.java:1)
    at com.google.common.util.concurrent.Futures$AsyncChainingFuture.doTransform(Futures.java:1442)
    at com.google.common.util.concurrent.Futures$AsyncChainingFuture.doTransform(Futures.java:1433)
    at com.google.common.util.concurrent.Futures$AbstractChainingFuture.run(Futures.java:1408)
    at com.google.common.util.concurrent.Futures$2$1.run(Futures.java:1177)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

@ghost ghost closed this as completed in f116fee Mar 8, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants