Permalink
Browse files

[FIXED JENKINS-25937] Treat BadPaddingException as an unloadable key …

…and continue.

(cherry picked from commit 6318b8d)

Conflicts:
	changelog.html
  • Loading branch information...
jglick authored and olivergondza committed Dec 5, 2014
1 parent 5e02457 commit 5ded56a8288dfcfb9e389ea85edc13cf49981a2a
Showing with 7 additions and 0 deletions.
  1. +7 −0 core/src/main/java/jenkins/security/DefaultConfidentialStore.java
@@ -16,6 +16,7 @@
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 @@ protected void store(ConfidentialKey key, byte[] payload) throws IOException {
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);

0 comments on commit 5ded56a

Please sign in to comment.