WildFly 与客户端证书:javax.net.ssl.SSLException:收到致命警报:unknown_ca

WildFly 与客户端证书:javax.net.ssl.SSLException:收到致命警报:unknown_ca

我正在尝试安装具有客户端证书授权的 wildfly9 服务器。为此,我必须:

  1. 在客户端上:创建自签名证书:

    keytool -genkey -keystore client.keystore -validity 3650 
        -keyalg RSA -keysize 4096 -storetype pkcs12 -alias myClient
    
  2. 在客户端:出口证书

    keytool -exportcert -keystore client.keystore -alias myClient 
        -storetype pkcs12 -file myClient.crt
    
  3. 在服务器上:将 crt 证书文件导入到 truststore

    keytool -import -file myClient.crt   
         -keystore /etc/pki/wildfly/client.truststore
    
  4. 在服务器上:调整 wildfly 配置(启用客户端证书身份验证):

    <security-realm name="UndertowRealm">
      <server-identities>
        <ssl>
          <keystore path="/etc/pki/wildfly/server.keystore" keystore-password="123456" alias="server" key-password="123456"/>
        </ssl>
      </server-identities>
      <authentication>
        <truststore path="/etc/pki/wildfly/client.truststore" keystore-password="123456"/>
        <local default-user="$local" skip-group-loading="true"/>
        <properties path="mgmt-users.properties" relative-to="jboss.server.config.dir"/>
      </authentication>
    </security-realm>
    ...
    <subsystem xmlns="urn:jboss:domain:undertow:2.0">
      <server name="default-server">
        <https-listener name="https" socket-binding="https" security-realm="UndertowRealm" verify-client="REQUIRED"/>
         ...
       </server>
     </subsystem>
    

客户端是一个 Python 脚本。对于此客户端,我需要 PEM 格式的证书和密钥。要导出 PEM 格式的证书,我需要执行以下操作(全部在客户端):

  1. 导出证书密钥:

    keytool -v -importkeystore -srckeystore client.keystore 
        -srcalias myClient -destkeystore myClient.key.tmp.pem 
        -deststoretype PKCS12 -destkeypass 123456
    
  2. 从密钥中删除密码(是的,当然我稍后也会通过更改文件模式来限制对密钥的访问):

    openssl pkcs12 -in myClient.key.tmp.pem -nocerts 
        -nodes > myClient.key.pem
    
    1. 删除 myClient.key.pem 中除“-----BEGIN PRIVATE KEY-----”和“-----END PRIVATE KEY-----”之外的所有内容

    2. 将证书导出为 PEM:

      keytool -exportcert -keystore 客户端.keystore -alias myClient -rfc -file myClient.pem

但每次我想要连接服务器时,都会在服务器上收到错误:

2016-10-31 09:50:55,102 DEBUG [io.undertow.request.io] (default I/O-1) Error reading request: javax.net.ssl.SSLException: Received fatal alert: unknown_ca
    at sun.security.ssl.Alerts.getSSLException(Alerts.java:208)
    at sun.security.ssl.SSLEngineImpl.fatal(SSLEngineImpl.java:1666)
    at sun.security.ssl.SSLEngineImpl.fatal(SSLEngineImpl.java:1634)
    at sun.security.ssl.SSLEngineImpl.recvAlert(SSLEngineImpl.java:1800)
    at sun.security.ssl.SSLEngineImpl.readRecord(SSLEngineImpl.java:1083)
    at sun.security.ssl.SSLEngineImpl.readNetRecord(SSLEngineImpl.java:907)
    at sun.security.ssl.SSLEngineImpl.unwrap(SSLEngineImpl.java:781)
    at javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:624)
    at org.xnio.ssl.JsseSslConduitEngine.engineUnwrap(JsseSslConduitEngine.java:688)
    at org.xnio.ssl.JsseSslConduitEngine.unwrap(JsseSslConduitEngine.java:620)
    at org.xnio.ssl.JsseSslConduitEngine.unwrap(JsseSslConduitEngine.java:574)
    at org.xnio.ssl.JsseSslStreamSourceConduit.read(JsseSslStreamSourceConduit.java:89)
    at org.xnio.conduits.ConduitStreamSourceChannel.read(ConduitStreamSourceChannel.java:127)
    at io.undertow.server.protocol.http.HttpReadListener.handleEventWithNoRunningRequest(HttpReadListener.java:150)
    at io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:128)
    at io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:56)
    at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
    at org.xnio.conduits.ReadReadyHandler$ChannelListenerHandler.readReady(ReadReadyHandler.java:66)
    at org.xnio.nio.NioSocketConduit.handleReady(NioSocketConduit.java:88)
    at org.xnio.nio.WorkerThread.run(WorkerThread.java:539)

如果我禁用客户端证书认证,一切都会好起来。所以客户端证书认证一定有问题。

有谁知道什么问题吗?

答案1

我们无法解决这个问题。我们有另一个安装(我们的测试系统),我们可以成功配置。但是。现在我们在 wildfly 服务器前面放置了一个 apache httpd 代理。apache 代理现在还管理客户端证书。这对我们来说很管用。

相关内容