You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2021/06/09 16:36:45 UTC

[tomcat] branch main updated: Integrate JSign for cross-platform builds with signed Windows binaries

This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
     new 9f391c9  Integrate JSign for cross-platform builds with signed Windows binaries
9f391c9 is described below

commit 9f391c998ee9adbc22acce2bbabbc2c6b8fc4172
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Wed Jun 9 17:36:25 2021 +0100

    Integrate JSign for cross-platform builds with signed Windows binaries
    
    Big thanks due to ebourg
---
 build.properties.default | 18 +++++++++++++--
 build.xml                | 59 ++++++++++++++++++++++++++++++------------------
 2 files changed, 53 insertions(+), 24 deletions(-)

diff --git a/build.properties.default b/build.properties.default
index 7572888..8cc72bb 100644
--- a/build.properties.default
+++ b/build.properties.default
@@ -77,9 +77,11 @@ org.apache.tomcat.util.net.NioSelectorShared=true
 gpg.exec=/path/to/gpg
 
 # Code signing of Windows installer
+# See https://infra.apache.org/digicert-use.html for setup instructions
 do.codesigning=false
-codesigning.exec=signtool.exe
-codesigning.certificate.thumbprint=5a606116432aba614c246d15e792f9e4bcf19cbf
+codesigning.pkcs11properties=${user.home}/.digicertone/pkcs11properties.cfg
+codesigning.alias=Tomcat-PMC-key-2021-04
+codesigning.digest=SHA-512
 
 # ----- Settings to use when downloading files -----
 trydownload.httpusecaches=true
@@ -323,3 +325,15 @@ migration-lib.checksum.value=cecc0fa3b5947dd52465ed395ba3f23f|19a3e36dec08bbc60a
 migration-lib.home=${base.path}/migration-${migration-lib.version}
 migration-lib.jar=${migration-lib.home}/jakartaee-migration-${migration-lib.version}-shaded.jar
 migration-lib.loc=${base-maven.loc}/org/apache/tomcat/jakartaee-migration/${migration-lib.version}/jakartaee-migration-${migration-lib.version}-shaded.jar
+
+# ----- JSign, version 3.1 or later -----
+jsign.version=3.1
+
+# checksums for JSign 3.1
+jsign.checksum.enable=true
+jsign.checksum.algorithm=MD5|SHA-1
+jsign.checksum.value=ed924fc86b7abe1dfe22fd8fd7e4c417|5736035f64805b2760a41ebc1ff11523f666f2c7
+
+jsign.home=${base.path}/jsign-${jsign.version}
+jsign.jar=${jsign.home}/jsign-${jsign.version}.jar
+jsign.loc=${base-maven.loc}/net/jsign/jsign/${jsign.version}/jsign-${jsign.version}.jar
diff --git a/build.xml b/build.xml
index 993f31f..77f9083 100644
--- a/build.xml
+++ b/build.xml
@@ -2622,18 +2622,15 @@ skip.installer property in build.properties" />
   </target>
 
   <target name="-installer-sign-uninstaller"
-      unless="skip.installer" depends="-installer-create-uninstaller"
+      unless="skip.installer" depends="-installer-create-uninstaller,setup-jsign"
       if="${do.codesigning}">
-    <exec executable="${codesigning.exec}" failonerror="true">
-      <arg value="sign"/>
-      <arg value="/sha1"/>
-      <arg value="${codesigning.certificate.thumbprint}"/>
-      <arg value="/fd"/>
-      <arg value="sha512"/>
-      <arg value="/tr"/>
-      <arg value="http://timestamp.digicert.com"/>
-      <arg value="${tomcat.dist}/Uninstall.exe"/>
-    </exec>
+    <jsign file="${tomcat.dist}/Uninstall.exe"
+        keystore="${codesigning.pkcs11properties}"
+        storepass="NONE"
+        storetype="PKCS11"
+        alias="${codesigning.alias}"
+        alg="${codesigning.digest}"
+        tsaurl="http://timestamp.digicert.com"/>
   </target>
 
   <target name="-installer" unless="skip.installer"
@@ -2655,17 +2652,14 @@ skip.installer property in build.properties" />
 
   <target name="installer-sign"
       description="Builds and optionally signs the Windows installer"
-      depends="-installer" if="${do.codesigning}" >
-    <exec executable="${codesigning.exec}" failonerror="true">
-      <arg value="sign"/>
-      <arg value="/sha1"/>
-      <arg value="${codesigning.certificate.thumbprint}"/>
-      <arg value="/fd"/>
-      <arg value="sha512"/>
-      <arg value="/tr"/>
-      <arg value="http://timestamp.digicert.com"/>
-      <arg value="${tomcat.release}/v${version}/bin/${final.name}.exe"/>
-    </exec>
+      depends="-installer,setup-jsign" if="${do.codesigning}" >
+    <jsign file="${tomcat.release}/v${version}/bin/${final.name}.exe"
+        keystore="${codesigning.pkcs11properties}"
+        storepass="NONE"
+        storetype="PKCS11"
+        alias="${codesigning.alias}"
+        alg="${codesigning.digest}"
+        tsaurl="http://timestamp.digicert.com"/>
     <!-- .exe has changed so need to redo checksums and OpenPGP signature -->
     <delete file="${tomcat.release}/v${version}/bin/${final.name}.exe.asc" />
     <delete file="${tomcat.release}/v${version}/bin/${final.name}.exe.sha512" />
@@ -3717,6 +3711,27 @@ Read the Building page on the Apache Tomcat documentation site for details on ho
 
   <!-- ======================= Macros, Taskdefs etc ======================== -->
 
+  <target name="download-jsign" >
+    <!-- Download jsign -->
+    <antcall target="downloadfile">
+      <param name="sourcefile" value="${jsign.loc}"/>
+      <param name="destfile" value="${jsign.jar}"/>
+      <param name="destdir" value="${jsign.home}"/>
+      <param name="checksum.enabled" value="${jsign.checksum.enabled}"/>
+      <param name="checksum.algorithm" value="${jsign.checksum.algorithm}"/>
+      <param name="checksum.value" value="${jsign.checksum.value}"/>
+    </antcall>
+  </target>
+
+  <target name="setup-jsign" depends="download-jsign">
+    <!-- Add jsign tasks to project -->
+    <path id="jsign.classpath">
+      <fileset file="${jsign.jar}" />
+    </path>
+
+    <taskdef name="jsign" classname="net.jsign.JsignTask" classpathref="jsign.classpath" />
+  </target>
+
   <target name="download-bnd" >
     <!-- Download bnd -->
     <antcall target="downloadfile">

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: [tomcat] branch main updated: Integrate JSign for cross-platform builds with signed Windows binaries

Posted by Rémy Maucherat <re...@apache.org>.
On Thu, Jun 10, 2021 at 12:08 AM Emmanuel Bourg <eb...@apache.org> wrote:

> Le 2021-06-09 21:09, Rémy Maucherat a écrit :
>
> > Caused by: sun.security.pkcs11.wrapper.PKCS11Exception:
> > CKR_FUNCTION_FAILED
> > at
> >
> jdk.crypto.cryptoki/sun.security.pkcs11.wrapper.PKCS11.C_SignFinal(Native
> > Method)
> > at
> >
> jdk.crypto.cryptoki/sun.security.pkcs11.P11Signature.engineSign(P11Signature.java:635)
> > ... 12 more
> > Try `java -jar jsign.jar --help' for more information.
> >
> > The cfg file is:
> > name=DigiCertONE
> > library="/home/remm/.digicertone/smpkcs11.so"
> > slotListIndex=0
> >
> > The .so is there (otherwise it would complain earlier). Also the smctl
> > tool
> > shows the key. I tried other algorithms but no success so far.
>
>
> You can try adding -Djava.security.debug=sunpkcs11, it should provide
> more info.
>

https://pastebin.com/nqNUix6j
So I think it shows the security provider [why was this hacked in as a fake
token card ??] works on init, but I didn't get any extra details on the
error.

Now I will try again with a clean environment instead of my bleeding edge
Fedora stuff.

Rémy


>
> Emmanuel Bourg
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>

Re: [tomcat] branch main updated: Integrate JSign for cross-platform builds with signed Windows binaries

Posted by Emmanuel Bourg <eb...@apache.org>.
Le 2021-06-09 21:09, Rémy Maucherat a écrit :

> Caused by: sun.security.pkcs11.wrapper.PKCS11Exception: 
> CKR_FUNCTION_FAILED
> at 
> jdk.crypto.cryptoki/sun.security.pkcs11.wrapper.PKCS11.C_SignFinal(Native 
> Method)
> at 
> jdk.crypto.cryptoki/sun.security.pkcs11.P11Signature.engineSign(P11Signature.java:635)
> ... 12 more
> Try `java -jar jsign.jar --help' for more information.
> 
> The cfg file is:
> name=DigiCertONE
> library="/home/remm/.digicertone/smpkcs11.so"
> slotListIndex=0
> 
> The .so is there (otherwise it would complain earlier). Also the smctl 
> tool
> shows the key. I tried other algorithms but no success so far.


You can try adding -Djava.security.debug=sunpkcs11, it should provide 
more info.

Emmanuel Bourg

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: [tomcat] branch main updated: Integrate JSign for cross-platform builds with signed Windows binaries

Posted by Rémy Maucherat <re...@apache.org>.
On Wed, Jun 9, 2021 at 6:40 PM Mark Thomas <ma...@apache.org> wrote:

> On 09/06/2021 17:36, markt@apache.org wrote:
> > This is an automated email from the ASF dual-hosted git repository.
> >
> > markt pushed a commit to branch main
> > in repository https://gitbox.apache.org/repos/asf/tomcat.git
> >
> >
> > The following commit(s) were added to refs/heads/main by this push:
> >       new 9f391c9  Integrate JSign for cross-platform builds with signed
> Windows binaries
> > 9f391c9 is described below
> >
> > commit 9f391c998ee9adbc22acce2bbabbc2c6b8fc4172
> > Author: Mark Thomas <ma...@apache.org>
> > AuthorDate: Wed Jun 9 17:36:25 2021 +0100
> >
> >      Integrate JSign for cross-platform builds with signed Windows
> binaries
>
> The signing works on Linux. I'm just testing it on Windows before
> back-porting.
>

-installer-sign-uninstaller:
    [jsign] Adding Authenticode signature to
/home/remm/Work/releases/tomcat-9.0.47/output/dist/Uninstall.exe

BUILD FAILED
/home/remm/Work/releases/tomcat-9.0.47/build.xml:2615: Couldn't sign
/home/remm/Work/releases/tomcat-9.0.47/output/dist/Uninstall.exe

With the command line and after getting a real standalone JVM, I'm still
getting:
[remm@omni releases]$ java -jar libs/jsign-3.1/jsign-3.1.jar --keystore
~/.digicertone/pkcs11properties.cfg --storepass NONE --storetype PKCS11
--alias "Tomcat-PMC-key-2021-04" --alg SHA-512 --tsaurl
http://timestamp.digicert.com tomcat-9.0.47/output/dist/Uninstall.exe
Adding Authenticode signature to tomcat-9.0.47/output/dist/Uninstall.exe
jsign: Couldn't sign tomcat-9.0.47/output/dist/Uninstall.exe
java.security.ProviderException:
sun.security.pkcs11.wrapper.PKCS11Exception: CKR_FUNCTION_FAILED
at
jdk.crypto.cryptoki/sun.security.pkcs11.P11Signature.engineSign(P11Signature.java:685)
at
java.base/java.security.Signature$Delegate.engineSign(Signature.java:1404)
at java.base/java.security.Signature.sign(Signature.java:713)
at
net.jsign.bouncycastle.operator.jcajce.JcaContentSignerBuilder$1.getSignature(Unknown
Source)
at net.jsign.bouncycastle.cms.SignerInfoGenerator.generate(Unknown Source)
at net.jsign.bouncycastle.cms.CMSSignedDataGenerator.generate(Unknown
Source)
at net.jsign.bouncycastle.cms.CMSSignedDataGenerator.generate(Unknown
Source)
at
net.jsign.asn1.authenticode.AuthenticodeSignedDataGenerator.generate(AuthenticodeSignedDataGenerator.java:50)
at
net.jsign.AuthenticodeSigner.createSignedData(AuthenticodeSigner.java:368)
at net.jsign.AuthenticodeSigner.sign(AuthenticodeSigner.java:339)
at net.jsign.SignerHelper.sign(SignerHelper.java:424)
at net.jsign.JsignCLI.execute(JsignCLI.java:111)
at net.jsign.JsignCLI.main(JsignCLI.java:40)
Caused by: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_FUNCTION_FAILED
at
jdk.crypto.cryptoki/sun.security.pkcs11.wrapper.PKCS11.C_SignFinal(Native
Method)
at
jdk.crypto.cryptoki/sun.security.pkcs11.P11Signature.engineSign(P11Signature.java:635)
... 12 more
Try `java -jar jsign.jar --help' for more information.

The cfg file is:
name=DigiCertONE
library="/home/remm/.digicertone/smpkcs11.so"
slotListIndex=0

The .so is there (otherwise it would complain earlier). Also the smctl tool
shows the key. I tried other algorithms but no success so far.

Rémy


> Mark
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>

Re: [tomcat] branch main updated: Integrate JSign for cross-platform builds with signed Windows binaries

Posted by Mark Thomas <ma...@apache.org>.
On 09/06/2021 17:36, markt@apache.org wrote:
> This is an automated email from the ASF dual-hosted git repository.
> 
> markt pushed a commit to branch main
> in repository https://gitbox.apache.org/repos/asf/tomcat.git
> 
> 
> The following commit(s) were added to refs/heads/main by this push:
>       new 9f391c9  Integrate JSign for cross-platform builds with signed Windows binaries
> 9f391c9 is described below
> 
> commit 9f391c998ee9adbc22acce2bbabbc2c6b8fc4172
> Author: Mark Thomas <ma...@apache.org>
> AuthorDate: Wed Jun 9 17:36:25 2021 +0100
> 
>      Integrate JSign for cross-platform builds with signed Windows binaries

The signing works on Linux. I'm just testing it on Windows before 
back-porting.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org