Skip to content

Commit

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

(cherry picked from commit 6318b8d)
  • Loading branch information
jglick committed Jan 9, 2015
1 parent 877f4b3 commit 16afb73
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion changelog.html
Expand Up @@ -55,7 +55,9 @@
<!-- Record your changes in the trunk here. -->
<div id="trunk" style="display:none"><!--=TRUNK-BEGIN=-->
<ul class=image>
<li class=>
<li class=bug>
After recent Java security updates, Jenkins would not gracefully recover from a deleted <code>secrets/master.key</code>.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-25937">issue 25937</a>)
</ul>
</div><!--=TRUNK-END=-->

Expand Down
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 16afb73

Please sign in to comment.