相互认证 - 空证书链

时间:2018-03-15 14:06:35

标签: java ssl ssl-certificate keytool mutual-authentication

我正在尝试设置相互(双向)SSL身份验证。最终,我将有一个mulesoft应用程序(作为客户端)调用webapp(作为服务器)。目前我正在测试使用Firefox浏览器作为客户端来简化测试。

我遵循了本教程 http://www.baeldung.com/x-509-authentication-in-spring-security

并设法使此工作正常。这使用服务器的自签名证书和客户端的自签名证书,该证书安装在firefox中以进行客户端调用。

到目前为止一直很好......

但是,一旦我尝试使用我公司签署的证书,我就会遇到问题。

所以我有一份我公司签署的客户证书。这是作为client.cer文件提供的。我可以查看详细信息,看看它是由公司中介发布的(后者又由公司根CA发布)

客户端CSR是使用

创建的
keytool -genkey -alias client -keyalg RSA -keysize 2048 -keystore client.jks -dname "CN=client-dev,OU=Dept, O=Company, L=London, ST=Greater London, C=GB"

keytool -certreq -alias client -file client.csr -keystore client.jks

我测试的下一步是尝试使用这个公司签名的client.cer文件在localhost上调用我的服务器(根据教程使用自签名证书)。

收到签名的client.cer文件后,我采取的步骤是......

  • 将公司Root.cer导入我用来生成my的密钥库 客户端证书签名请求。
  • 将公司Intermediate.cer导入同一个密钥库。
  • 将client.cer导入同一个密钥库
  • 然后我从此密钥库导出一个p12文件,并将其作为我的客户端证书安装到firefox中。

我用来执行此操作的命令如下

keytool -import -trustcacerts -alias primaryintermediate -file Root.cer -keystore client.jks -storepass <pwd>

keytool -import -trustcacerts -alias secondaryintermediate -file Int.cer -keystore client.jks -storepass <pwd>

keytool -import -trustcacerts -alias client -file client.cer -keystore client.jks -storepass <pwd>

keytool -importkeystore -srcalias client -srckeystore client.jks -srcstorepass <pwd> -destkeystore "client.p12" -deststorepass <pwd> -deststoretype PKCS12

然而,当我尝试从firefox点击我的localhost应用程序端点并查看日志输出时,我看到服务器端SSL握手成功但在客户端握手中出现“null cert chain”错误。因此,以下步骤将成功

  • 的ClientHello
  • 服务器问候
  • 证书
  • CertificateRequest
  • ServerHelloDone
  • 证书 - 此处发生错误

日志的相关部分看起来像这样......

*** CertificateRequest
Cert Types: RSA, DSS, ECDSA
Supported Signature Algorithms: SHA512withECDSA, SHA512withRSA, SHA384withECDSA, SHA384withRSA, SHA256withECDSA, SHA256withRSA, SHA224withECDSA, SHA224withRSA, SHA1withECDSA, SHA1withRSA, SHA1withDSA, MD5withRSA
Cert Authorities:
<CN=Root>
<CN=client-dev, OU=Dept, O=Company, L=London, ST=Greater London, C=GB>
<CN=Intermediate, DC=HBEU, DC=ADROOT, DC=Company>
*** ServerHelloDone
https-jsse-nio-8443-exec-1, WRITE: TLSv1.2 Handshake, length = 2710
https-jsse-nio-8443-exec-2, READ: TLSv1.2 Handshake, length = 77
*** Certificate chain
<Empty>
***
https-jsse-nio-8443-exec-2, fatal error: 42: null cert chain
javax.net.ssl.SSLHandshakeException: null cert chain

我不清楚我做错了什么但是假设我必须错误地创建了p12文件?

有人能指出我正确的方向吗?

0 个答案:

没有答案