From 60ef031f7890b4554b7b61d209e34d5628fd679c Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Tue, 24 Jun 2014 11:21:32 -0700 Subject: [PATCH] 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 --- .../boot/loader/ExecutableArchiveLauncher.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/ExecutableArchiveLauncher.java b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/ExecutableArchiveLauncher.java index 01d560c61db..eeae719bc9c 100644 --- a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/ExecutableArchiveLauncher.java +++ b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/ExecutableArchiveLauncher.java @@ -30,7 +30,7 @@ import org.springframework.boot.loader.archive.Archive.EntryFilter; /** * Base class for executable archive {@link Launcher}s. - * + * * @author Phillip Webb * @author Andy Wilkinson */ @@ -78,11 +78,11 @@ public abstract class ExecutableArchiveLauncher extends Launcher { @Override protected ClassLoader createClassLoader(URL[] urls) throws Exception { - Set copy = new LinkedHashSet(); + Set copy = new LinkedHashSet(urls.length); ClassLoader loader = getDefaultClassLoader(); if (loader instanceof URLClassLoader) { for (URL url : ((URLClassLoader) loader).getURLs()) { - if (!this.javaAgentDetector.isJavaAgentJar(url)) { + if (addDefaultClassloaderUrl(urls, url)) { copy.add(url); } } @@ -93,6 +93,16 @@ public abstract class ExecutableArchiveLauncher extends Launcher { return super.createClassLoader(copy.toArray(new URL[copy.size()])); } + private boolean addDefaultClassloaderUrl(URL[] urls, URL url) { + String jarUrl = "jar:" + url + "!/"; + for (URL nestedUrl : urls) { + if (nestedUrl.equals(url) || nestedUrl.toString().equals(jarUrl)) { + return false; + } + } + return !this.javaAgentDetector.isJavaAgentJar(url); + } + /** * Determine if the specified {@link JarEntry} is a nested item that should be added * to the classpath. The method is called once for each entry.