提交 16afb73b 编写于 作者: J Jesse Glick

[FIXED JENKINS-25937] Treat BadPaddingException as an unloadable key and continue.

(cherry picked from commit 6318b8d8)
上级 877f4b37
......@@ -55,7 +55,9 @@ Upcoming changes</a>
<!-- 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=-->
......
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册