Skip to content

Commit 60ef031

Browse files
author
Phillip Webb
committed
Fix "signer information does not match" error
Update ExecutableArchiveLauncher so that `-cp` URLs are not added when they are already contained as nested JARs. This prevents a SecurityException "signer information does not match error" when using signed jars. The root cause of the issue was that the primary JAR file was on the default classpath with the URL "file:....jar" and in the main URL set as "jar:file:....jar". It is now filtered so that only the "jar:" variant is added. Fixes gh-1134
1 parent 1f1a7e0 commit 60ef031

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/ExecutableArchiveLauncher.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
/**
3232
* Base class for executable archive {@link Launcher}s.
33-
*
33+
*
3434
* @author Phillip Webb
3535
* @author Andy Wilkinson
3636
*/
@@ -78,11 +78,11 @@ public boolean matches(Entry entry) {
7878

7979
@Override
8080
protected ClassLoader createClassLoader(URL[] urls) throws Exception {
81-
Set<URL> copy = new LinkedHashSet<URL>();
81+
Set<URL> copy = new LinkedHashSet<URL>(urls.length);
8282
ClassLoader loader = getDefaultClassLoader();
8383
if (loader instanceof URLClassLoader) {
8484
for (URL url : ((URLClassLoader) loader).getURLs()) {
85-
if (!this.javaAgentDetector.isJavaAgentJar(url)) {
85+
if (addDefaultClassloaderUrl(urls, url)) {
8686
copy.add(url);
8787
}
8888
}
@@ -93,6 +93,16 @@ protected ClassLoader createClassLoader(URL[] urls) throws Exception {
9393
return super.createClassLoader(copy.toArray(new URL[copy.size()]));
9494
}
9595

96+
private boolean addDefaultClassloaderUrl(URL[] urls, URL url) {
97+
String jarUrl = "jar:" + url + "!/";
98+
for (URL nestedUrl : urls) {
99+
if (nestedUrl.equals(url) || nestedUrl.toString().equals(jarUrl)) {
100+
return false;
101+
}
102+
}
103+
return !this.javaAgentDetector.isJavaAgentJar(url);
104+
}
105+
96106
/**
97107
* Determine if the specified {@link JarEntry} is a nested item that should be added
98108
* to the classpath. The method is called once for each entry.

0 commit comments

Comments
 (0)