mqtt-home / miele-to-mqtt-gw

Apache License 2.0
10 stars 2 forks source link

java.lang.SecurityException with the new Build starting the App #25

Closed AleksCee closed 3 years ago

AleksCee commented 3 years ago

Error: A JNI error has occurred, please check your installation and try again Exception in thread "main" java.lang.SecurityException: Invalid signature file digest for Manifest main attributes at sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:330) at sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:263) at java.util.jar.JarVerifier.processEntry(JarVerifier.java:318) at java.util.jar.JarVerifier.update(JarVerifier.java:230) at java.util.jar.JarFile.initializeVerifier(JarFile.java:383) at java.util.jar.JarFile.ensureInitialization(JarFile.java:612) at java.util.jar.JavaUtilJarAccessImpl.ensureInitialization(JavaUtilJarAccessImpl.java:69) at sun.misc.URLClassPath$JarLoader$2.getManifest(URLClassPath.java:991) at java.net.URLClassLoader.defineClass(URLClassLoader.java:451) at java.net.URLClassLoader.access$100(URLClassLoader.java:74) at java.net.URLClassLoader$1.run(URLClassLoader.java:369) at java.net.URLClassLoader$1.run(URLClassLoader.java:363) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:362) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:495)

AleksCee commented 3 years ago

Same issue with the Release-Build-JAR

AleksCee commented 3 years ago

If i delete the the RSA-File: zip -d miele-to-mqtt-gw.jar 'META-INF/ECLIPSE.RSA' deleting: META-INF/ECLIPSE.RSA

the JAR can be started. But why is it now in the JAR?

AleksCee commented 3 years ago

Ok I have fixed it with the hint from: https://stackoverflow.com/questions/34855649/invalid-signature-file-digest-for-manifest-main-attributes-exception-while-tryin/64263739#64263739

here it my patch

diff --git a/src/pom.xml b/src/pom.xml
index 15625e1..1631d6d 100644
--- a/src/pom.xml
+++ b/src/pom.xml
@@ -30,6 +30,16 @@
                        <configuration>
                            <finalName>miele-to-mqtt-gw</finalName>
                            <shadedArtifactAttached>true</shadedArtifactAttached>
+                           <filters>
+                               <filter>
+                                   <artifact>*:*</artifact>
+                                   <excludes>
+                                       <exclude>META-INF/*.SF</exclude>
+                                       <exclude>META-INF/*.DSA</exclude>
+                                       <exclude>META-INF/*.RSA</exclude>
+                                   </excludes>
+                               </filter>
+                           </filters>
                            <transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>de.rnd7.mieletomqtt.Main</mainClass>
@@ -97,4 +107,4 @@
            <version>1.2.3</version>
        </dependency>
    </dependencies>
-</project>
\ No newline at end of file
+</project>
philipparndt commented 3 years ago

Thanks for the investigation!

Sorry I had no time this morning to deploy the jar to my production environment. I deployed a new release and updated my image on Raspberry. Works fine now 👍