From 6318b8d800abdf8b280f4e1b8ce8bf22e49242ad Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Fri, 5 Dec 2014 12:07:50 -0500 Subject: [PATCH] [FIXED JENKINS-25937] Treat BadPaddingException as an unloadable key and continue. --- changelog.html | 4 +++- .../java/jenkins/security/DefaultConfidentialStore.java | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/changelog.html b/changelog.html index bf195b6647..ae9896ecb1 100644 --- a/changelog.html +++ b/changelog.html @@ -55,7 +55,9 @@ Upcoming changes diff --git a/core/src/main/java/jenkins/security/DefaultConfidentialStore.java b/core/src/main/java/jenkins/security/DefaultConfidentialStore.java index 989769b32a..7821f492fd 100644 --- a/core/src/main/java/jenkins/security/DefaultConfidentialStore.java +++ b/core/src/main/java/jenkins/security/DefaultConfidentialStore.java @@ -16,6 +16,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.security.GeneralSecurityException; import java.security.SecureRandom; +import javax.crypto.BadPaddingException; import org.apache.commons.io.IOUtils; /** @@ -107,6 +108,12 @@ public class DefaultConfidentialStore extends ConfidentialStore { return verifyMagic(bytes); } catch (GeneralSecurityException e) { throw new IOException("Failed to load the key: "+key.getId(),e); + } catch (IOException x) { + if (x.getCause() instanceof BadPaddingException) { + return null; // broken somehow + } else { + throw x; + } } finally { IOUtils.closeQuietly(cis); IOUtils.closeQuietly(fis);