2011-11-18 143 views
6

我在CAcert創建了一個SSL服務器證書。當我嘗試從Java程序獲取此服務器頁面(如下圖),我得到爲什麼java嗆cacert.org上的證書:「keyCertSign位未設置」?

Exception in thread "main" javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: CA key usage check failed: keyCertSign bit is not set 

任何人都知道可能會導致什麼呢?

  • 我已經嘗試創建由他們的類1和類3根證書籤署的證書,結果相同。
  • 當我嘗試獲取來自其他兩個站點使用CAcert.org證書的頁面並沒有發生的錯誤:https://www.cacert.orghttps://pause.perl.org(導致我相信根&類從cacert.org 3個證書被正確安裝我的系統)。
  • 我可以在keytool -keystore /etc/ssl/certs/java/cacerts -list中看到cacert.org證書。
  • 是的,我知道很少有web瀏覽器隨cacert.org root和class 3 certs一起提供。
  • 該證書是*.an.example.com的通配證書(真正的域編輯)。

下面是我使用測試Java代碼:

class Test { 
    public static void main(String args[]) throws Exception { 
     java.net.URL url = new java.net.URL(args[0]); 
     java.io.InputStream s = url.openStream(); 
    } 
} 

full stack trace似乎不添加任何有用的信息。

keytool(1)手冊頁確實提到

Extensions can be marked critical to indicate that the extension should 
be checked and enforced/used. For example, if a certificate has the 
KeyUsage extension marked critical and set to "keyCertSign" then if this 
certificate is presented during SSL communication, it should be rejected, 
as the certificate extension indicates that the associated private key 
should only be used for signing certificates and not for SSL use. 

,但我查了證書,並且在「證書密鑰用法」擴展名不說「簽名」,還標有「不嚴重」。

對不起,我不想透露我的域名或證書,但我可以啓動一個服務器進行測試,如果有必要的話。

+1

發現此問題:http://www.ericsimmerman.com/resolving-a-ca-key-usage-check-failed-keycert – Thilo

+0

@Thilo - 很好找。我再次檢查,我似乎有正確安裝和配置SSLCertificateChainFile。 –

+0

@Thilo - 我回來了,你是對的! [鏈文件搞砸了](http://wiki.cacert.org/SimpleApacheCert?action=AttachFile&do=view&target=CAcert_chain.pem)(CAcert.org人:修正!)。我用'cat class3.crt root.crt> chain.pem'自己創建了一個鏈文件,並且隱藏的「keyCertSign位未設置」錯誤消失。隨意添加此作爲答案,我會接受它。 –

回答

0

在我看來,證書不會用於SSL通信。
I.e.它被標記爲CA證書,但由於沒有設置證書籤名的擴展名,Java會拒絕它。
對於這樣的事情,Java有時更嚴格,而瀏覽器更寬鬆。