ebourg / jsign

Java implementation of Microsoft Authenticode for signing Windows executables, installers & scripts
https://ebourg.github.io/jsign
Apache License 2.0
259 stars 108 forks source link

Lower case storetype is no longer supported #115

Closed MNeuling closed 6 months ago

MNeuling commented 2 years ago

This is the ant task. After changing the JSign version from 3.1 to 4.0 the error occurs.

                                    <jsign file="${packageDir}/${exeFileName}.exe"
                                          name="${productFullName}"
                                          url="${productURL}"
                                          keystore="${app.keystore}"
                                          storetype="${app.storetype}"
                                          alias="${app.alias}"
                                          storepass="${app.storepass}"
                                          tsaurl="${app.tsaurl}"
                                          tsmode="${app.tsmode}"
                                          alg="${app.signalg}"/>
ebourg commented 2 years ago

What kind of keystore do you use? Could you copy the stacktrace please?

MNeuling commented 2 years ago

It is a PKCS12 keystore. app.storetype=pkcs12 app.signalg=SHA-256 app.tsaurl=http://timestamp.comodoca.com/rfc3161 app.tsmode=RFC3161

This is the stacktrace from the error log.

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:3.0.0:run (default) on project cd-exec: An Ant BuildException has occured: No certificate found in the keystore E:\jarsigning\CodeSigning.pfx
[ERROR] around Ant part ...<jsign file="E:\git\app\exec\target/package/App.exe" storetype="pkcs12" storepass="..." name="App" alias="appstart-cert2020" tsaurl="http://timestamp.comodoca.com/rfc3161" keystore="E:/jarsigning
/CodeSigning.pfx" tsmode="RFC3161" alg="SHA-256" url="http://www.mysite.com" />... @ 60:356 in E:\git\app\exec\target\antrun\build-main.xml
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:3.0.0:run (default) on project cd-exec: An Ant BuildException has occured: No certificate found in the keystore E:\jarsigning\CodeSigning.pfx
around Ant part ...<jsign file="E:\git\app\exec\target/package/App.exe" storetype="pkcs12" storepass="..." name="App" alias="app-cert2020" tsaurl="http://timestamp.comodoca.com/rfc3161" keystore="E:/jarsigning/CodeSigning.pfx" tsmode="RFC3161" alg="SHA-256" url="http://www.mysite.com" />... @ 60:356 in E:\git\app\exec\target\antrun\build-main.xml
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoExecutionException: An Ant BuildException has occured: No certificate found in the keystore E:\jarsigning\CodeSigning.pfx
around Ant part ...<jsign file="E:\git\app\exec\target/package/App.exe" storetype="pkcs12" storepass="..." name="App" alias="app-cert2020" tsaurl="http://timestamp.comodoca.com/rfc3161" keystore="E:/jarsigning/CodeSigning.pfx" tsmode="RFC3161" alg="SHA-256" url="http://www.mysite.com" />... @ 60:356 in E:\git\app\exec\target\antrun\build-main.xml
    at org.apache.maven.plugins.antrun.AntRunMojo.execute (AntRunMojo.java:308)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.tools.ant.BuildException: No certificate found in the keystore E:\jarsigning\CodeSigning.pfx
    at net.jsign.JsignTask.execute (JsignTask.java:183)
    at org.apache.tools.ant.UnknownElement.execute (UnknownElement.java:299)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute (DispatchUtils.java:99)
    at org.apache.tools.ant.Task.perform (Task.java:350)
    at org.apache.tools.ant.taskdefs.Sequential$$Lambda$114/0x0000000000000000.accept (Unknown Source)
    at java.util.Vector.forEach (Vector.java:1277)
    at org.apache.tools.ant.taskdefs.Sequential.execute (Sequential.java:67)
    at net.sf.antcontrib.logic.IfTask.execute (IfTask.java:197)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute (DispatchUtils.java:99)
    at org.apache.tools.ant.TaskAdapter.execute (TaskAdapter.java:155)
    at org.apache.tools.ant.UnknownElement.execute (UnknownElement.java:299)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute (DispatchUtils.java:99)
    at org.apache.tools.ant.Task.perform (Task.java:350)
    at org.apache.tools.ant.Target.execute (Target.java:449)
    at org.apache.tools.ant.Target.performTasks (Target.java:470)
    at org.apache.tools.ant.Project.executeSortedTargets (Project.java:1401)
    at org.apache.tools.ant.Project.executeTarget (Project.java:1374)
    at org.apache.maven.plugins.antrun.AntRunMojo.execute (AntRunMojo.java:287)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: net.jsign.SignerException: No certificate found in the keystore E:\jarsigning\CodeSigning.pfx
    at net.jsign.SignerHelper.build (SignerHelper.java:385)
    at net.jsign.SignerHelper.sign (SignerHelper.java:500)
    at net.jsign.JsignTask.execute (JsignTask.java:181)
    at org.apache.tools.ant.UnknownElement.execute (UnknownElement.java:299)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute (DispatchUtils.java:99)
    at org.apache.tools.ant.Task.perform (Task.java:350)
    at org.apache.tools.ant.taskdefs.Sequential$$Lambda$114/0x0000000000000000.accept (Unknown Source)
    at java.util.Vector.forEach (Vector.java:1277)
    at org.apache.tools.ant.taskdefs.Sequential.execute (Sequential.java:67)
    at net.sf.antcontrib.logic.IfTask.execute (IfTask.java:197)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute (DispatchUtils.java:99)
    at org.apache.tools.ant.TaskAdapter.execute (TaskAdapter.java:155)
    at org.apache.tools.ant.UnknownElement.execute (UnknownElement.java:299)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute (DispatchUtils.java:99)
    at org.apache.tools.ant.Task.perform (Task.java:350)
    at org.apache.tools.ant.Target.execute (Target.java:449)
    at org.apache.tools.ant.Target.performTasks (Target.java:470)
    at org.apache.tools.ant.Project.executeSortedTargets (Project.java:1401)
    at org.apache.tools.ant.Project.executeTarget (Project.java:1374)
    at org.apache.maven.plugins.antrun.AntRunMojo.execute (AntRunMojo.java:287)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
MNeuling commented 1 year ago

@ebourg Are there any news solving the problem? I've tried also version 4.1 and 4.2 but it still doesn't work.

ebourg commented 1 year ago

And it works with Jsign 3.1 with the exact same keystore?

MNeuling commented 1 year ago

Yes, it works. Without exception and no further problems. Only since Version 4.x the exception occurs.

ebourg commented 1 year ago

Did you try with a relative path instead of an absolute path when specifying the location of the keystore file?

ebourg commented 1 year ago

@MNeuling What is the output of keytool -list -keystore E:\jarsigning\CodeSigning.pfx ?

MNeuling commented 6 months ago

Now I found out what the problem is. Since version 4.0 the value of property app.storetype must be uppercase. If you use app.storetype=pkcs12 the exception occurs. If you use app.storetype=PKCS12 everything works fine.

ebourg commented 6 months ago

That's a regression, I'll fix it.

ebourg commented 6 months ago

Also recent versions will report the storetype is incorrect:

java.lang.IllegalArgumentException: Unknown keystore type 'pkcs12' (expected types: JKS, JCEKS, PKCS12, PKCS11, OPENPGP, OPENSC, PIV, NITROKEY, YUBIKEY, AWS, AZUREKEYVAULT, DIGICERTONE, ESIGNER, GOOGLECLOUD, HASHICORPVAULT, ETOKEN)