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

Jenkins JIRA | Jesse Glick | 2 years ago
tip
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  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

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

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

    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