我刚从Comodo购买了代码签名证书。我现在正在尝试对Webstart / JNLP文件进行签名,以便可以分发它,但是却收到“应用程序被Java安全性阻止”消息。
java - 在Webstart/JNLP中部署JavaFX-LMLPHP

我正在使用Maven构建:



   <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.8</version>
        <executions>
            <execution>
                <phase>package</phase>
                <configuration>
                    <target>
                        <taskdef name="jfxdeploy" classname="com.sun.javafx.tools.ant.DeployFXTask" classpathref="maven.plugin.classpath" />
                        <taskdef name="jfxsignjar" classname="com.sun.javafx.tools.ant.FXSignJarTask" classpathref="maven.plugin.classpath" />

                        <jfxdeploy outdir="${project.build.directory}/jnlp"
                                   outfile="jnlp-test"
                                   embedJNLP="true">

                            <info title="JNLP Test"
                                  vendor="Foo Bar"
                                  description=""/>
                            <application name="${project.name}"
                                         mainClass="com.foo.CheckboxTableExample" />
                            <resources>
                                <fileset dir="${project.build.directory}" includes="*.jar" />
                            </resources>

                            <permissions elevated="true"/>

                        </jfxdeploy>

                        <!-- Sign all the jars in the deploy directory -->
                        <jfxsignjar destdir="${project.build.directory}/jnlp"
                                    keyStore="cert.pfx"
                                    storetype="pkcs12"
                                    storePass="****"
                                    alias="myalias">
                            <fileset dir="${project.build.directory}/jnlp" includes="*.jar" />
                        </jfxsignjar>

                    </target>
                </configuration>
                <goals>
                    <goal>run</goal>
                </goals>
            </execution>
        </executions>

        <dependencies>
            <dependency>
                <groupId>com.oracle</groupId>
                <artifactId>ant-javafx</artifactId>
                <version>8.0</version>
                <systemPath>${java.home}/../lib/ant-javafx.jar</systemPath>
                <scope>system</scope>
            </dependency>
        </dependencies>
    </plugin>


Maven可以正常编译,没有错误,通过查看jar中的SIGNATURES.BSF文件,我可以看到jar已签名。但是我对为什么仍然出现此错误感到困惑。

我还清除了Java中的缓存/临时文件设置,以确保它未引用旧版本。

谁能阐明这一点?

编辑:

我的JNLP输出是:

<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0" xmlns:jfx="http://javafx.com" href="jnlp-test.jnlp">
  <information>
    <title>JNLP Test</title>
    <vendor>Foo Bar</vendor>
    <description></description>
    <offline-allowed/>
  </information>
  <resources>
    <j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"/>
    <jar href="test-jnlp-1.0.jar" size="6834" download="eager" />
  </resources>
<security>
  <all-permissions/>
</security>
  <jfx:javafx-desc  width="0" height="0" main-class="com.foo.CheckboxTableExample"  name="Test JNLP" />
  <update check="background"/>
</jnlp>


JaNeLA的输出清楚地表明我有一些错误:

Content type application/xml does not equal expected type of application/x-java-jnlp-file
cvc-complex-type.2.4.a: Invalid content was found starting with element 'security'. One of '{resources, application-desc, applet-desc, component-desc, installer-desc}' is expected.
cvc-complex-type.2.4.a: Invalid content was found starting with element 'security'. One of '{resources, application-desc, applet-desc, component-desc, installer-desc}' is expected.
XML encoding not known, but declared as utf-8
Codebase not specified.  Defaulting to file:/D:/workspace/test-jnlp/target/jnlp/
Resource 'test-jnlp-1.0.jar' declared as size '6834' but is actually '10571'.
The resource download at test-jnlp-1.0.jar can be optimized by removing the (default) value of download='eager'.
The resource download at test-jnlp-1.0.jar can be optimized by removing the (default) value of main='false'.
It might be possible to optimize the start-up of the app. by  specifying download='lazy' for the test-jnlp-1.0.jar resource.
Lazy downloads might not work as expected for test-jnlp-1.0.jar unless the download 'part' is specified.


最后,显然我的jar没有按照jarsign -verify命令签名

jar is unsigned. (signatures missing or not parsable)


我不确定jfxsigner命令出了什么问题。

编辑2:
现在,我知道jar签名不起作用,我尝试在命令行上使用jarsigner手动进行操作,并收到有关颁发给我的证书的错误

Warning:
The signer's certificate chain is not validated.
No -tsa or -tsacert is provided and this jar is not timestamped. Without a timestamp, users may not be able to validate this jar after the signer certificate's expiration date (2016-08-03) or after any future revocation date.


所以这是我需要向Comodo处理的问题。

最佳答案

我已经解决了我的问题。

第一个问题是我在Windows中拥有Comodo的Rogue根证书。需要删除该文件并安装适当的文件。

第二个问题是我需要将pfx文件和证书导入密钥库。我实际上不确定这是否必要,但是我在一系列事件中做到了。

第三个问题是“ No -tsa”错误。我认为这是Comodo给我的证明书存在的问题,他们没有说其他话。但是通过搜索,我发现在jarsigner中添加-tsa http://timestamp.digicert.com摆脱了该警告。

第四个问题是jxsignjar不起作用。首先,jar签名失败时它没有报告错误。接下来,我需要将signjar放在部署之前(我的错误)。最后,它不允许使用-tsa选项。我最终使用了一个蚂蚁任务给罐子签名。

我使用JaNeLA工具检查了jnlp文件。它是一个很酷的工具,但是我不认为它已更新为支持JavaFX。例如,它在上标记一个错误

<jfx:javafx-desc  width="0" height="0" main-class="com.foo.CheckboxTableExample"  name="Test JNLP" />


它想要一些旧格式的东西

<application-desc main-class="com.foo.CheckboxTableExample" />


感谢您的帮助,安德鲁。现在,我需要弄清楚Webstart是否比安装程序更好。

07-28 02:01