如何检查证书过期后Java Web Start应用程序是否将继续工作

时间:2015-10-09 20:17:06

标签: java certificate code-signing trusted-timestamp

我们使用CA(Thawte)的代码签名证书签署了我们的Java Web Start应用程序。签名带有时间戳(我们将-tca enter image description here参数传递给jarsigner工具),以便在证书过期后生效。目前,当证书有效时,该应用程序工作正常。但是当我们尝试更改本地时间以模拟证书到期时,应用程序将无法启动。我们得到以下例外:

import numpy as np
import matplotlib.pyplot as plt

fig = plt.figure()

list_date = ['2015', '2016', '2017']

data_dict_A = {'2015': {1: 254, 2:567, 3:786}, 
             '2016':{1:567, 2:189, 3:145},
             '2017': {1:89, 2:123, 3:190}}
data_dict_B = {'2015': {1: 154, 2:597, 3:286}, 
             '2016':{1:967, 2:789, 3:345},
             '2017': {1:189, 2:223, 3:290}}
data_dict_C = {'2015': {1: 354, 2:591, 3:486}, 
             '2016':{1:267, 2:289, 3:367},
             '2017': {1:489, 2:256, 3:390}}

length = np.arange(1, 4, 1)
width = 0.2

for each_date in list_date:
    ax = fig.add_subplot(111)

    for d_A, v_A in data_dict_A.items():
        if d_A == each_date:
            graph_A = plt.bar(length-0.2, v_A.values(), width, color="blue", align='center')

    for d_B, v_B in data_dict_B.items():
        if d_B == each_date:
            graph_B = plt.bar(length, v_B.values(), width, color="red", align='center')

    for d_C, v_C in data_dict_C.items():
        if d_C == each_date:
            graph_C = plt.bar(length+0.2, v_C.values(), width, color="yellow", align='center')

    plt.legend((graph_A[0], graph_B[0], graph_C[0]), ('A', 'B', 'C'), loc='best')
    plt.title(str(each_date))
    fig.savefig( str(each_date) +'.png')
    fig.clf()

证书有效期为2015年10月9日至2017年11月8日。

我们尝试使用jarsigner工具验证签名的JAR。所有文件似乎都有时间戳:

java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Responder's certificate not within the validity period
at com.sun.deploy.security.RevocationChecker.checkOCSP(Unknown Source)
at com.sun.deploy.security.RevocationChecker.check(Unknown Source)
at com.sun.deploy.security.TrustDecider.checkRevocationStatus(Unknown Source)
at com.sun.deploy.security.TrustDecider.getValidationState(Unknown Source)
at com.sun.deploy.security.TrustDecider.validateChain(Unknown Source)
at com.sun.deploy.security.TrustDecider.isAllPermissionGrantedInt(Unknown Source)
at com.sun.deploy.security.TrustDecider.isAllPermissionGranted(Unknown Source)
at com.sun.javaws.security.AppPolicy.grantUnrestrictedAccess(Unknown Source)
at com.sun.javaws.security.JNLPSignedResourcesHelper.checkSignedResourcesHelper(Unknown Source)
at com.sun.javaws.security.JNLPSignedResourcesHelper.checkSignedResources(Unknown Source)
at com.sun.javaws.Launcher.prepareResources(Unknown Source)
at com.sun.javaws.Launcher.prepareAllResources(Unknown Source)
at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
at com.sun.javaws.Launcher.launch(Unknown Source)
at com.sun.javaws.Main.launchApp(Unknown Source)
at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
at com.sun.javaws.Main.access$000(Unknown Source)
at com.sun.javaws.Main$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.security.cert.CertPathValidatorException: Responder's certificate not within the validity period
at sun.security.provider.certpath.OCSPResponse.verify(Unknown Source)
at sun.security.provider.certpath.OCSP.check(Unknown Source)
at sun.security.provider.certpath.OCSP.check(Unknown Source)
at sun.security.provider.certpath.OCSP.check(Unknown Source)
at com.sun.deploy.security.RevocationChecker$2.run(Unknown Source)
at com.sun.deploy.security.RevocationChecker$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.deploy.security.RevocationChecker.doPrivilegedOCSPCheck(Unknown Source)
... 20 more
Caused by: java.security.cert.CertificateExpiredException: NotAfter: Thu Dec 17 00:59:59 CET 2015
at sun.security.x509.CertificateValidity.valid(Unknown Source)
at sun.security.x509.X509CertImpl.checkValidity(Unknown Source)
... 28 more

所以jarsigner输出似乎是正确的。有人可以确认这确实意味着签名有时间戳吗?

我们注意到,如果我们仅在前面几(3)天更改当地时间,那么该应用就可以运行。但如果我们更改(周),那么我们就会得到例外。 CA服务器是否检查客户端本地时间是否有效?如果我们如何模拟证书过期?谢谢。

2 个答案:

答案 0 :(得分:4)

原因和解决方法

您的异常堆栈跟踪显示使用OCSP(在线证书状态协议)的证书吊销检查失败,因为您的测试日期OCSP响应者证书到期(不是因为您的证书)。

要执行测试,请尝试在Java控制面板中关闭证书吊销检查。

还要确保您的证书尚未被永久接受(使用"恢复安全提示"在Java控制面板中)。

关于带时间戳签名的说明

目前(在j8u66至j8u144之前)加盖时间戳签名并不能持久阻止签名过期。 Web Start不会抱怨您的证书到期。但是,它会阻止您的申请和状态证书已过期或尚未生效[&34;当您的TSA证书到期时。即使在Timestamp:输出的keytool -printcert部分中显示的TSA证书的到期日期之后,您也可以使用日期对此进行测试。

根据您的应用类型,这可能是一个严重的问题。时间戳目前只会给你一些时间,直到应用程序启动被阻止。我们在嵌入式环境中遇到此问题,并在此问题上打开了Oracle支持请求。

2016-01-07更新:Oracle支持的最终答案是"没有错误。这种行为是预期的和有意的。肯定没有变化。"。这意味着有没有办法在没有过期的情况下签署申请。

2017-11-06更新:尽管甲骨文2016年的声明,即使在使用Web Start j8u151(使用j8u144和j8u151进行测试,未测试j9)的TSA证书到期日期之后,签名仍然有效。如果这是出于故意或错误的话,可疑。

答案 1 :(得分:1)

JDK keytool也可用于检查时间戳:

keytool -printcert -jarfile app.jar

时间戳报告应如下所示:

    Timestamp:

Owner: CN=GeoTrust 2048-bit Timestamping Signer 1, O=GeoTrust Inc, C=US
Issuer: CN=Symantec Time Stamping Services CA - G2, O=Symantec Corporation, C=US
Serial number: 5fd693fab098e3f4677bb8cb672c229e
Valid from: Thu Jun 11 02:00:00 CEST 2015 until: Wed Dec 30 00:59:59 CET 2020
Certificate fingerprints:
     MD5:  2B:51:8D:A4:11:F1:43:C7:84:62:5A:41:95:BB:5E:05
     SHA1: D7:1D:45:62:C6:33:36:7C:34:E3:66:CF:B7:6F:B9:7B:05:AF:34:B4
     SHA256: DC:DA:D2:91:F5:32:D5:BD:FC:E6:9D:06:41:A1:45:57:85:74:E0:D5:B9:8F:19:00:6C:19:AB:2E:9D:F9:96:42
     Signature algorithm name: SHA1withRSA
     Version: 3