java.io.IOException: javax.crypto.BadPaddingException: Given final block not properly padded

Jenkins JIRA | Jesse Glick | 2 years ago
  1. 0

    [JENKINS-25937] "Given final block not properly padded" after deleting master.key after Java security update - Jenkins JIRA

    jenkins-ci.org | 1 year ago
    java.io.IOException: javax.crypto.BadPaddingException: Given final block not properly padded
  2. 0

    Recently core tests have started failing: https://jenkins.ci.cloudbees.com/job/core/job/jenkins-core-validated-merge/307/testReport/junit/jenkins.security/DefaultConfidentialStoreTest/roundtrip/ {code:none} java.io.IOException: javax.crypto.BadPaddingException: Given final block not properly padded at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:811) at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:676) at com.sun.crypto.provider.AESCipher.engineDoFinal(AESCipher.java:313) at javax.crypto.Cipher.doFinal(Cipher.java:1970) at javax.crypto.CipherInputStream.getMoreData(CipherInputStream.java:112) at javax.crypto.CipherInputStream.read(CipherInputStream.java:233) at javax.crypto.CipherInputStream.read(CipherInputStream.java:209) at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1792) at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1769) at org.apache.commons.io.IOUtils.copy(IOUtils.java:1744) at org.apache.commons.io.IOUtils.toByteArray(IOUtils.java:462) at jenkins.security.DefaultConfidentialStore.load(DefaultConfidentialStore.java:106) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:230) at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116) at jenkins.security.DefaultConfidentialStoreTest.roundtrip(DefaultConfidentialStoreTest.groovy:52) {code} This is reproducible when the test is run on Java 8, but not 7. It looks like a real bug, not just a test failure; this part of the test checks what happens when {{master.key}} is deleted and recreated, which presumably is a rare event, so it is not surprising if this was never noticed by users.

    Jenkins JIRA | 2 years ago | Jesse Glick
    java.io.IOException: javax.crypto.BadPaddingException: Given final block not properly padded
  3. 0

    Recently core tests have started failing: https://jenkins.ci.cloudbees.com/job/core/job/jenkins-core-validated-merge/307/testReport/junit/jenkins.security/DefaultConfidentialStoreTest/roundtrip/ {code:none} java.io.IOException: javax.crypto.BadPaddingException: Given final block not properly padded at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:811) at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:676) at com.sun.crypto.provider.AESCipher.engineDoFinal(AESCipher.java:313) at javax.crypto.Cipher.doFinal(Cipher.java:1970) at javax.crypto.CipherInputStream.getMoreData(CipherInputStream.java:112) at javax.crypto.CipherInputStream.read(CipherInputStream.java:233) at javax.crypto.CipherInputStream.read(CipherInputStream.java:209) at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1792) at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1769) at org.apache.commons.io.IOUtils.copy(IOUtils.java:1744) at org.apache.commons.io.IOUtils.toByteArray(IOUtils.java:462) at jenkins.security.DefaultConfidentialStore.load(DefaultConfidentialStore.java:106) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:230) at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116) at jenkins.security.DefaultConfidentialStoreTest.roundtrip(DefaultConfidentialStoreTest.groovy:52) {code} This is reproducible when the test is run on Java 8, but not 7. It looks like a real bug, not just a test failure; this part of the test checks what happens when {{master.key}} is deleted and recreated, which presumably is a rare event, so it is not surprising if this was never noticed by users.

    Jenkins JIRA | 2 years ago | Jesse Glick
    java.io.IOException: javax.crypto.BadPaddingException: Given final block not properly padded
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    [~gagravarr] noticed that one of our old test files fails a Tika test now with PDFBox 1.8.7 and Java 1.6. I just tested the pure PDFBox app built with PDFBox 1.8.8-SNAPSHOT, and I'm getting the same exception with Java 1.6 and Java 1.7. Stacktrace: {noformat} ExtractText failed with the following exception: java.io.IOException: javax.crypto.BadPaddingException: Given final block not properly padded at javax.crypto.CipherInputStream.getMoreData(CipherInputStream.java:118) at javax.crypto.CipherInputStream.read(CipherInputStream.java:236) at javax.crypto.CipherInputStream.read(CipherInputStream.java:212) at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(SecurityHandler.java:316) at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decryptStream(SecurityHandler.java:421) at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decrypt(SecurityHandler.java:390) at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decryptObject(SecurityHandler.java:365) at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.proceedDecryption(SecurityHandler.java:196) at org.apache.pdfbox.pdmodel.encryption.StandardSecurityHandler.decryptDocument(StandardSecurityHandler.java:158) at org.apache.pdfbox.pdmodel.PDDocument.openProtection(PDDocument.java:1598) at org.apache.pdfbox.ExtractText.startExtraction(ExtractText.java:216) at org.apache.pdfbox.ExtractText.main(ExtractText.java:85) at org.apache.pdfbox.PDFBox.main(PDFBox.java:58) Caused by: javax.crypto.BadPaddingException: Given final block not properly padded at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:811) at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:676) at com.sun.crypto.provider.AESCipher.engineDoFinal(AESCipher.java:423) at javax.crypto.Cipher.doFinal(Cipher.java:1708) at javax.crypto.CipherInputStream.getMoreData(CipherInputStream.java:112) ... 12 more {noformat} java version "1.7.0_71" OpenJDK Runtime Environment (rhel-2.5.3.1.el6-x86_64 u71-b14) OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode) and java version "1.6.0_33" OpenJDK Runtime Environment (IcedTea6 1.13.5) (rhel-1.13.5.0.el6_6-x86_64) OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode)

    Apache's JIRA Issue Tracker | 2 years ago | Tim Allison
    java.io.IOException: javax.crypto.BadPaddingException: Given final block not properly padded
  6. 0

    [~gagravarr] noticed that one of our old test files fails a Tika test now with PDFBox 1.8.7 and Java 1.6. I just tested the pure PDFBox app built with PDFBox 1.8.8-SNAPSHOT, and I'm getting the same exception with Java 1.6 and Java 1.7. Stacktrace: {noformat} ExtractText failed with the following exception: java.io.IOException: javax.crypto.BadPaddingException: Given final block not properly padded at javax.crypto.CipherInputStream.getMoreData(CipherInputStream.java:118) at javax.crypto.CipherInputStream.read(CipherInputStream.java:236) at javax.crypto.CipherInputStream.read(CipherInputStream.java:212) at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(SecurityHandler.java:316) at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decryptStream(SecurityHandler.java:421) at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decrypt(SecurityHandler.java:390) at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decryptObject(SecurityHandler.java:365) at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.proceedDecryption(SecurityHandler.java:196) at org.apache.pdfbox.pdmodel.encryption.StandardSecurityHandler.decryptDocument(StandardSecurityHandler.java:158) at org.apache.pdfbox.pdmodel.PDDocument.openProtection(PDDocument.java:1598) at org.apache.pdfbox.ExtractText.startExtraction(ExtractText.java:216) at org.apache.pdfbox.ExtractText.main(ExtractText.java:85) at org.apache.pdfbox.PDFBox.main(PDFBox.java:58) Caused by: javax.crypto.BadPaddingException: Given final block not properly padded at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:811) at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:676) at com.sun.crypto.provider.AESCipher.engineDoFinal(AESCipher.java:423) at javax.crypto.Cipher.doFinal(Cipher.java:1708) at javax.crypto.CipherInputStream.getMoreData(CipherInputStream.java:112) ... 12 more {noformat} java version "1.7.0_71" OpenJDK Runtime Environment (rhel-2.5.3.1.el6-x86_64 u71-b14) OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode) and java version "1.6.0_33" OpenJDK Runtime Environment (IcedTea6 1.13.5) (rhel-1.13.5.0.el6_6-x86_64) OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode)

    Apache's JIRA Issue Tracker | 2 years ago | Tim Allison
    java.io.IOException: javax.crypto.BadPaddingException: Given final block not properly padded

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.io.IOException

      javax.crypto.BadPaddingException: Given final block not properly padded

      at com.sun.crypto.provider.CipherCore.doFinal()
    2. com.sun.crypto
      AESCipher.engineDoFinal
      1. com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:811)
      2. com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:676)
      3. com.sun.crypto.provider.AESCipher.engineDoFinal(AESCipher.java:313)
      3 frames
    3. Android Platform
      CipherInputStream.read
      1. javax.crypto.Cipher.doFinal(Cipher.java:1970)
      2. javax.crypto.CipherInputStream.getMoreData(CipherInputStream.java:112)
      3. javax.crypto.CipherInputStream.read(CipherInputStream.java:233)
      4. javax.crypto.CipherInputStream.read(CipherInputStream.java:209)
      4 frames
    4. Commons IO
      IOUtils.toByteArray
      1. org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1792)
      2. org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1769)
      3. org.apache.commons.io.IOUtils.copy(IOUtils.java:1744)
      4. org.apache.commons.io.IOUtils.toByteArray(IOUtils.java:462)
      4 frames
    5. jenkins.security
      DefaultConfidentialStore.load
      1. jenkins.security.DefaultConfidentialStore.load(DefaultConfidentialStore.java:106)
      1 frame
    6. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      4. java.lang.reflect.Method.invoke(Method.java:606)
      4 frames
    7. Groovy
      AbstractCallSite.call
      1. org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:230)
      2. org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53)
      3. org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
      4. org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
      5. org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
      5 frames
    8. jenkins.security
      DefaultConfidentialStoreTest.roundtrip
      1. jenkins.security.DefaultConfidentialStoreTest.roundtrip(DefaultConfidentialStoreTest.groovy:52)
      1 frame