Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ssl ActiveMQ Artemis“;needClientAuth=true";“出错”;空客户端证书链。”;消息(AMQ222208)_Ssl_Keystore_Activemq Artemis_Jks_Truststore - Fatal编程技术网

Ssl ActiveMQ Artemis“;needClientAuth=true";“出错”;空客户端证书链。”;消息(AMQ222208)

Ssl ActiveMQ Artemis“;needClientAuth=true";“出错”;空客户端证书链。”;消息(AMQ222208),ssl,keystore,activemq-artemis,jks,truststore,Ssl,Keystore,Activemq Artemis,Jks,Truststore,我有ActiveMQ Artemis群集,具有共享存储的活动备份模式,版本2.17.0。SSL与此群集一起使用 我从Kafka集群中获取了密钥库/信任库文件,该集群完全可以使用双向TLS。我将这些文件与Artemis一起重复使用,它也可以很好地工作。但是,当我在URL字符串中启用needClientAuth=true时,问题就出现了 以下是文档说明的内容: needClientAuth 此属性仅适用于接受器。它告诉连接到此接收器的客户端需要双向SSL。有效值为true或false。默认值为fal

我有ActiveMQ Artemis群集,具有共享存储的活动备份模式,版本2.17.0。SSL与此群集一起使用

我从Kafka集群中获取了密钥库/信任库文件,该集群完全可以使用双向TLS。我将这些文件与Artemis一起重复使用,它也可以很好地工作。但是,当我在URL字符串中启用
needClientAuth=true
时,问题就出现了

以下是文档说明的内容:

needClientAuth

此属性仅适用于
接受器
。它告诉连接到此接收器的客户端需要双向SSL。有效值为
true
false
。默认值为
false

因此,如果我想实现双向TLS,我必须使用此选项。然后,服务器和客户端都必须有自己的密钥库/信任库对。在我的例子中,服务器和客户端都是相同的


当我在acceptor URL字符串中有
needClientAuth=true
时,我使用Artemis CLI连接到Artemis群集,这就是我在CLI输出中得到的结果:

Connection failed::Failed to create session factory
这就是Artemis实例所说的:

WARN  [org.apache.activemq.artemis.core.server] AMQ222208: SSL handshake failed for client from /123.123.123.123:36788: javax.net.ssl.SSLHandshakeException: Empty client certificate chain.

正如我所说,提到的keystore/truststore与Kafka配合良好,没有问题。但是,它不适用于ActiveMQ Artemis。如果我从
acceptor
URL字符串中删除
needClientAuth=true
,一切正常

以下是生成密钥库/信任库的方法:

# Generate private key and CSR
openssl req -new -newkey rsa:2048 -nodes -days 365 -subj '/CN=something.com/OU=XXX/O=Company/L=City/ST=City/C=XX' -keyout private.key -out mycsr.csr

# Upload CSR to magic website, get back CA and signed certificate.
# ...

# Since CA is chain, and you cannot import chain into keystore/truststore, split into multiple files: ca1.cer and ca2.cer.
# ...

# Create truststore.jks
keytool -importcert -noprompt -alias ca1 -file ca1.cer -keystore truststore.jks
keytool -importcert -noprompt -alias ca2 -file ca2.cer -keystore truststore.jks

# Because it's impossible to create JKS keystore out of private key, first generate PKCS12 keystore:
openssl pkcs12 -inkey private.key -in certificate.cer -export -out keystore.p12

# Now convert PKCS12 keystore to JKS keystore:
keytool -importkeystore -srckeystore keystore.p12 -srcstoretype pkcs12 -destkeystore keystore.jks -deststoretype jks

# Since above command added only a private key, we also need to add an issued certificate:
keytool -importcert -noprompt -alias certificate -file certificate.cer -keystore keystore.jks

# Some client's (in Kafka) does not work if CA is not added to keystore, so add it:
keytool -importcert -noprompt -alias ca1 -file ca1.cer -keystore keystore.jks
keytool -importcert -noprompt -alias ca2 -file ca2.cer -keystore keystore.jks

# End up with the following files:
keystore.jks
truststore.jks
---------
ca.cer
certificate.cer
private.key
接受者URL(带
needClientAuth=true
):

使用ActiveMQ Artemis CLI连接时,我传递以下URL:

tcp://server.com:1234?sslEnabled=true;keyStorePath=/opt/ssl/truststore.jks;keyStorePassword=123;trustStorePath=/opt/ssl/truststore.jks;trustStorePassword=123
我缺少什么?

经纪人和客户都需要有自己的证书。您似乎只创建了一个证书,并在代理和客户端上使用它

例如,代理需要在其密钥库中拥有自己的证书,该密钥库提供给客户机,客户机在其信任库中拥有该证书。然后,客户机需要在其密钥库中拥有自己的证书,并将其呈现给代理,代理拥有的证书就是其信任库

据我所知,你没有这样做。看看ActiveMQ Artemis附带的示例。它包含使用自签名证书运行所需的所有
keytool
命令。一旦您使用简单的自签名证书启动并运行此功能,您就可以继续使用由证书颁发机构签名的证书

值得注意的是,如果您使用的是由证书颁发机构签名的证书,那么您只需在代理和客户机上注册,就不需要处理任何单独的信任库。客户端和代理将隐式信任由您的CA签名的证书


最后,您在ActiveMQ Artemis CLI中使用的URL看起来不正确,因为
keystrepath
引用的是信任库
/opt/ssl/truststore.jks

您可以共享Artemis CLI使用的连接URL和代理配置中定义的接受者吗?@DomenicoFrancescoBruscino我更新了我的帖子。在底部找到它们。我觉得你的接收器和连接器URL不错,这个问题应该是由于一个坏的证书。我将启用SSL调试,将
-Djavax.net.debug=SSL
添加到
artemis.profile
文件中定义的
JAVA_ARGS
变量中。非常感谢您澄清证书的用法!看来我还有很多东西要学。但是,在更正
keystrepath
后,该问题得到解决。我不敢相信我自己一开始就没有注意到这一点。非常感谢。
tcp://server.com:1234?sslEnabled=true;keyStorePath=/opt/ssl/truststore.jks;keyStorePassword=123;trustStorePath=/opt/ssl/truststore.jks;trustStorePassword=123