2011-04-12 49 views
4

我試圖用這個指南
(以及其他一些來自互聯網)來與公司簽訂的.pfx證書一罐小程序歸檔:
http://www.globalsign.com/support/ordering-guides/SignJavaCodeAppletsPFX.pdf如何使用.pfx文件簽名java applet?

一切似乎都很正常,但是當我嘗試牛逼運行蘋果通過瀏覽器我看到
'發佈者'是未知(不可信)。當我去詳細信息時,我可以看到正確的公司
名稱和證書供應商(GlobalSign)。爲什麼它沒有正確顯示爲已知/可信?

的一件事看起來可疑對我來說是命令的輸出
的jarsigner -verify -verbose -certs Applet.jar:

(...) 
    sm  1936 Wed Apr 13 03:00:50 CEST 2011 org/my/Applet.class 

    X.509, CN=CompanyName, O=CompanyName, L=Tilst, ST=ProperState, C=DK 
    [certificate is valid from 18.02.10 14:58 to 18.02.13 14:58] 

    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 

所以看起來像「K =至少一個證書密鑰庫中被發現'缺少
(應該是smk,它是sm)。它是否僅部分簽名?或者是什麼?

是否可能由GlobalSign給我的.pfx文件在某種程度上是錯誤的
不足以簽署小程序?對於正常的可執行文件,它工作得很好...

任何想法? ;)

編輯

@Jcs

看起來,你是完全正確的。我用keytool檢查了我的PFX文件,我得到:

Your keystore contains 1 entry 

Alias name: company_alias 
Creation date: Apr 13, 2011 
Entry type: PrivateKeyEntry 
Certificate chain length: 1 
Certificate[1]: 

因此看起來像鏈是不完整的。
我不知道,如果它很重要,但也有例如像一些擴展:

#1: ObjectId: (some_numbers_here) Criticality=true 
KeyUsage [ 
    DigitalSignature 
] 

#2: ObjectId: (some_numbers_here) Criticality=false 
AuthorityInfoAccess [ 
    [ 
    accessMethod: (some_numbers_here) 
    accessLocation: URIName: http://secure.globalsign.net/cacert/ObjectSign.crt] 
] 
(...) 

的問題是:是我的PFX文件完全錯誤的,或者不知何故,我需要GlobalSign根補充呢?

+0

對於下載指南不感困擾,但是您是否創建了'pfx'(我從來沒有聽說過)證書? – 2011-04-13 07:46:42

+0

.pfx是一種PKCS#12文件,與示例.p12相同。這.pfx文件我從其他項目(c + +)得到它正常工作。 – 2011-04-13 09:06:32

+0

這並不回答我的問題,我將重複。*「您是否創建了**'pfx'...證書?」* – 2011-04-13 09:12:42

回答

0

非常感謝所有人,尤其是JCS :)
我終於發現,.pfx文件只是進口不當。
我問我的老闆與所有可能的路徑/連鎖/證書導入我從頭包括現在工程:)
因此,如果任何人都會有類似的問題,我的建議是試圖讓/重新導入證書
- 與簽署方法相比,證書本身相當麻煩。

2

根據您的文章,似乎簽名證書鏈中只有一個證書。我驗證了一個applet我籤(這個小程序正常工作在瀏覽器中)

(...) 
sm  2419 Thu Mar 31 15:49:14 CEST 2011 org/xml/sax/helpers/XMLReaderFactory.class 

     X.509, CN=Company Name, O=Company Name, L=Paris, ST=Ile de France, C=FR 
     [certificate is valid from 8/4/10 2:00 AM to 8/4/12 1:59 AM] 
     X.509, CN=Thawte Code Signing CA - G2, O="Thawte, Inc.", C=US 
     [certificate is valid from 2/8/10 1:00 AM to 2/8/20 12:59 AM] 
     [KeyUsage extension does not support code signing] 

(...) 

我們可以看到,有鏈中的兩個證,因爲我的簽名證書已被Thawte的代碼簽名CA頒發

在你的情況下,如果jarsigner輸出中只有一個證書,它可能表示中間CA丟失,我很難懷疑GlobalSign直接從根CA(它在java信任存儲區中)頒發證書。因此,當加載小程序並驗證簽名時,JVM將無法在簽名證書和GlobalSign根CA之間重建證書鏈,從而解釋當前行爲。

也許PKF文件不包含該中間CA.隨着OpenSSL您可以檢查有多少證書存在:

[[email protected]:~/]$ openssl pkcs12 -in myfile.pfx 

keytool

[[email protected]:~/]$ keytool -list -v -storetype pkcs12 -keystore myfile.pfx 
Enter keystore password: 
Keystore type: PKCS12 
Keystore provider: SunJSSE 

Your keystore contains 1 entry 

Alias name: 2 
Creation date: Aug 4, 2010 
Entry type: PrivateKeyEntry 
Certificate chain length: 2  <-- the chain length is here. 
Certificate[1]: 
(...) 
+0

你是對的:)我編輯了我的第一篇文章的更多細節。 – 2011-04-13 09:53:52