Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-45835

BadPaddingException when trying to sign an apk

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Major Major
    • android-signing-plugin
    • None
    • Jenkins 2.60.2/Signing plugin 2.2.5/Credentials plugin 2.1.14

      I generated P12 file with the command

      keytool -importkeystore -srckeystore KEY.jks -destkeystore dest.p12 -srcstoretype JKS -deststoretype PKCS12 -deststorepass PASSWORD -srcalias alias -destalias alias
      

      Created credentials using the p12 file, and provided the PASSWORD, I have this error when building my apk

      13:45:14 [APP] $ echo '"resolving effective environment"'
      13:45:14 FATAL: Error reading signing key from key store credential ALIAS: Get Key failed: Given final block not properly padded
      13:45:14 java.security.UnrecoverableKeyException: Get Key failed: Given final block not properly padded
      13:45:14 	at sun.security.pkcs12.PKCS12KeyStore.engineGetKey(PKCS12KeyStore.java:410)
      13:45:14 	at sun.security.pkcs12.PKCS12KeyStore.engineGetEntry(PKCS12KeyStore.java:1282)
      13:45:14 	at java.security.KeyStore.getEntry(KeyStore.java:1521)
      13:45:14 	at org.jenkinsci.plugins.androidsigning.SigningComponents.fromCredentials(SigningComponents.java:50)
      13:45:14 	at org.jenkinsci.plugins.androidsigning.SignApksBuilder.perform(SignApksBuilder.java:294)
      13:45:14 	at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:81)
      13:45:14 	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
      13:45:14 	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:735)
      13:45:14 	at hudson.model.Build$BuildExecution.build(Build.java:206)
      13:45:14 	at hudson.model.Build$BuildExecution.doRun(Build.java:163)
      13:45:14 	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:490)
      13:45:14 	at hudson.model.Run.execute(Run.java:1735)
      13:45:14 	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      13:45:14 	at hudson.model.ResourceController.execute(ResourceController.java:97)
      13:45:14 	at hudson.model.Executor.run(Executor.java:405)
      13:45:14 Caused by: javax.crypto.BadPaddingException: Given final block not properly padded
      13:45:14 	at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:989)
      13:45:14 	at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:845)
      13:45:14 	at com.sun.crypto.provider.PKCS12PBECipherCore.implDoFinal(PKCS12PBECipherCore.java:399)
      13:45:14 	at com.sun.crypto.provider.PKCS12PBECipherCore$PBEWithSHA1AndDESede.engineDoFinal(PKCS12PBECipherCore.java:431)
      13:45:14 	at javax.crypto.Cipher.doFinal(Cipher.java:2165)
      13:45:14 	at sun.security.pkcs12.PKCS12KeyStore.engineGetKey(PKCS12KeyStore.java:348)
      13:45:14 	... 14 more
      13:45:14 ERROR: Error reading signing key from key store credential ALIAS: Get Key failed: Given final block not properly padded
      

      Is there a solution for this ?
      Thanks for the help.

            restjohn Robert St. John
            aminecmi Amine Bou
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: