从小程序安全警告中摆脱“未知”发布者
我正在尝试签署一个小程序,以便发布者不会显示为“未知”:
我为一个组织工作,我们有自己的证书颁发机构,证书链如下:ORG Root CA > ORG Trusted Certification Authority > Yann39 (me :D)
我申请了一个证书,他们给了我一个链接,让我把它放到浏览器中。然后我将其导出(从Firefox)以获取我命名为mystore.p12的PKCS#12文件。
然后我做了以下操作来签署我的小程序:
/* TO KNOW THE ALIAS */
c:\testrep>keytool -list -storetype pkcs12 -keystore mystore.p12
Enter keystore password: ********
Keystore type: pkcs12
Keystore provider: SunJSSE
Your keystore contains 1 entry
id de yann39, Oct 24, 2012, keyEntry,
Certificate fingerprint (MD5): D7:E3:83:1D:C1:40:68:72:5F:A8:6F:AC:3A:EA:DD:47
/* CREATE FAKE CLASS FILE AND BUILD A JAR */
c:\testrep>echo test > test.class
c:\testrep>C:\oracle\dev10gr2\jdk\bin\jar cf0 test_applet.jar test.class
/* SIGN THE JAR */
c:\testrep>C:\oracle\dev10gr2\jdk\bin\jarsigner -verbose -storetype pkcs12 -keystore mystore.p12 test_applet.jar "id de yann39"
Enter Passphrase for keystore: ********
updating: META-INF/MANIFEST.MF
adding: META-INF/ID_DE_YA.SF
adding: META-INF/ID_DE_YA.RSA
signing: test.class
/* VERIFY THE SIGNATURE */
c:\testrep>C:\oracle\dev10gr2\jdk\bin\jarsigner -verify -verbose -certs test_applet.jar
132 Wed Oct 24 17:49:52 CEST 2012 META-INF/MANIFEST.MF
185 Wed Oct 24 17:49:52 CEST 2012 META-INF/ID_DE_YA.SF
4801 Wed Oct 24 17:49:52 CEST 2012 META-INF/ID_DE_YA.RSA
0 Wed Oct 24 17:48:36 CEST 2012 META-INF/
sm 0 Wed Oct 24 17:47:46 CEST 2012 test.class
X.509, CN=Yann39, CN=794324, CN=myname, OU=Users, OU=Organic Units,
DC=myorg, DC=ch
X.509, CN=ORG Trusted Certification Authority, DC=myorg, DC=ch
X.509, CN=ORG Root CA, DC=myorg, DC=ch
s = signature was verified
m = entry is listed in manifest
k = at least one certificate was found in keystore
i = at least one certificate was found in identity scope
jar verified.
c:\testrep>
然后,我使用以下方法将 appled 加载到我的应用程序中:
<object id="mytestapplet" width="0" height="0" style="position:absolute" type="application/x-java-applet">
<param name="archive" value="https://myhost.ch/rep/test_applet.jar">
<param name="code" value="test">
<param name="scriptable" value="true">
<param name="mayscript" value="no">
</object>
我读了一些这样的帖子:如何使用.pfx文件对java小程序进行签名?似乎我应该在从jar中验证签名文件时获得,这不仅意味着在密钥库中找不到证书。smi
sm
所以我认为证书链不完整,但是当运行以下命令时,我看到情况并非如此:
c:\testrep>keytool -list -v -storetype pkcs12 -keystore mystore.p12
Enter keystore password: ********
Keystore type: pkcs12
Keystore provider: SunJSSE
Your keystore contains 1 entry
Alias name: id de yann39
Creation date: Oct 24, 2012
Entry type: keyEntry
Certificate chain length: 3
Certificate[1]:
Owner: CN=Yann39, CN=794324, CN=myname, OU=Users, OU=Organic Units,
DC=myorg, DC=ch
Issuer: CN=ORG Trusted Certification Authority, DC=myorg, DC=ch
Serial number: 12d21eb200200000a02b
Valid from: Mon Jun 25 14:16:00 CEST 2011 until: Wed Jun 24 14:16:00 CEST 2013
Certificate fingerprints:
MD5: D7:E3:83:1D:C1:41:78:72:5F:A8:6D:BD:3A:ED:DD:48
SHA1: 24:31:1D:25:02:98:0D:F8:28:6A:F1:0E:E8:BB:04:7E:51:E2:E9:66
Certificate[2]:
Owner: CN=ORG Trusted Certification Authority, DC=myorg, DC=ch
Issuer: CN=ORG Root CA, DC=myorg, DC=ch
Serial number: 601fab4c000000000003
Valid from: Tue Oct 02 11:36:53 CEST 2006 until: Mon Oct 02 11:47:53 CEST 2016
Certificate fingerprints:
MD5: 51:A1:EA:33:21:2C:71:60:A1:6F:F1:22:92:A8:51:8D
SHA1: 66:CD:70:13:27:68:F3:C2:08:F3:BE:5F:BF:D4:17:BD:85:9D:10:65
Certificate[3]:
Owner: CN=ORG Root CA, DC=myorg, DC=ch
Issuer: CN=ORG Root CA, DC=myorg, DC=ch
Serial number: 7dc0d089138d1d804b2e68e21b947412
Valid from: Tue Oct 02 10:55:19 CEST 2006 until: Sat Oct 02 11:01:47 CEST 2026
Certificate fingerprints:
MD5: A2:CE:DC:7D:F5:60:D7:2C:5E:B5:29:74:9D:51:F9:49
SHA1: DA:D8:7F:63:95:90:A2:E4:D4:1D:B9:48:FD:F4:C3:5C:FC:2B:B6:A3
*******************************************
*******************************************
c:\testrep>
链条似乎很好。
但我仍然收到带有“未知”发布者的安全警告。为什么?
编辑 25-十月-2012
我忘了说它使用Internet Explorer(“签名已被验证”,Publisher是“Yann39”),而不是使用Chrome或Firefox。
我尝试使用自签名证书:
keytool -genkey -alias myalias -storetype PKCS12 -keystore mykeystore.p12 -dname "cn=Yann39, ou=UN, o=ORG, st=Geneva, c=CH"
keytool -list -v -storetype pkcs12 -keystore mykeystore.p12
echo test > test.class
C:\oracle\dev10gr2\jdk\bin\jar cf0 myapplet.jar test.class
C:\oracle\dev10gr2\jdk\bin\jarsigner -verbose -storetype pkcs12 -keystore mykeystore.p12 myapplet.jar "myalias"
C:\oracle\dev10gr2\jdk\bin\jarsigner -verify -verbose -certs myapplet.jar
它既不能在IE中工作,也不能在Firefox或Chrome中工作,正常。
我试图从我的组织添加2个受信任的证书,但它失败了:
keytool -import -alias "myalias_root" -file ORGRooTCA.crt -storetype pkcs12 -keystore mykeystore.p12
keytool -import -alias "myalias_auth" -file ORGTrustedCertificationAuthority.crt -storetype pkcs12 -keystore mykeystore.p12
错误为:
keytool error: java.security.KeyStoreException: TrustedCertEntry not supported
我仍然不明白为什么在验证签名时它说在密钥库()中找不到证书。sm
编辑 02-十一月-2012
我终于得到了证书颁发机构的回复。由于代码签名证书仅用于测试(我们的组织不支持),因此它们不提供任何帮助,并且关闭了我的票证...
2 个证书 ORG Root CA 和 ORG Trusted Certificate Authority 在 3 个浏览器(IE、Firefox、Chrome)中受信任。运行我的小程序时,我仍然在IE中获得预期的结果:
- 名称:小程序
- 发布者: Yann39
- 寄件人: https://myhost.ch
但不是在Firefox和Chrome中:
- 名称:测试
- 发布者:未知
- 寄件人: https://myhost.ch
另一件奇怪的事情是,正如你所看到的,IE引用的是HTML中使用的标签的ID(小程序),而Firefox和Chrome引用的是主类(test)的名称。<object>
我认为发布者也是如此,IE正在查看RDN(Yann39),而Firefox和Chrome正在查看RDN,并且找不到,因为它没有在我的证书中定义。CN
O
如果有人有更多关于浏览器如何检查证书的信息,请分享。
谢谢。