Skip to content

Commit

Permalink
[FIXED JENKINS-25937] Treat BadPaddingException as an unloadable key …
Browse files Browse the repository at this point in the history
…and continue.

(cherry picked from commit 6318b8d)

Conflicts:
	changelog.html
  • Loading branch information
jglick authored and olivergondza committed Dec 21, 2014
1 parent 5e02457 commit 5ded56a
Showing 1 changed file with 7 additions and 0 deletions.
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -107,6 +108,12 @@ protected byte[] load(ConfidentialKey key) 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);
Expand Down

0 comments on commit 5ded56a

Please sign in to comment.