2011-11-18 141 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有时更严格,而浏览器更宽松。