我有一个仅支持 TLSv1.2 和密码 {ecdhe_ecdsa,aes_256_cbc,sha384} 的 RabbitMQ 服务器(带有 Erlang OTP 18.1 的 RabbitMQ 版本 3.6.0)。我正在尝试使用 AMQP 从 Java 客户端连接到它。源代码如下所示:
final SSLContext context = SSLContext.getInstance("TLSv1.2");
context.init(keyManagerFactory.getKeyManagers(), trustManagerFactory.getTrustManagers(), null);
SSLContext.setDefault(context);
final String[] enabledCipherSuites = { "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384" };
final SSLParameters defaultParams = context.getDefaultSSLParameters();
defaultParams.setCipherSuites(enabledCipherSuites);
final SSLParameters supportedParams = context.getSupportedSSLParameters();
supportedParams.setCipherSuites(enabledCipherSuites);
ConnectionFactory factory = new ConnectionFactory();
factory.useSslProtocol(context);
factory.setHost(RABBITMQ_ADMIN_HOST);
factory.setPort(RABBITMQ_CLIENT_PORT_SSL);
factory.setUsername(RABBITMQ_ADMIN_USER);
factory.setPassword(RABBITMQ_ADMIN_PWD);
return factory.newConnection();
这是 RabbitMQ 配置文件的片段:
{ssl_options, [{cacertfile, "cacert.pem"},
{certfile, "cert.pem"},
{keyfile, "key.pem"},
{verify, verify_peer},
{versions, ['tlsv1.2']},
{ciphers, [{ecdhe_ecdsa,aes_256_cbc,sha384}]},
{fail_if_no_peer_cert, true}]}
问题是,当客户端尝试连接到服务器时,服务器不允许连接并出现以下错误:
=ERROR REPORT==== 4-Aug-2016::23:15:24 ===
SSL: hello: tls_handshake.erl:167:Fatal error: insufficient security
在客户端,我们看到一个 Java 异常被抛出,如下所示:
Received fatal alert: insufficient_security
Thread-1 sun.security.ssl.Alerts.getSSLException(Alerts.java:192),
sun.security.ssl.Alerts.getSSLException(Alerts.java:154),
sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1991),
sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1098),
sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1344),
sun.security.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:721),
sun.security.ssl.AppOutputStream.write(AppOutputStream.java:122),
java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82),
java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140),
java.io.DataOutputStream.flush(DataOutputStream.java:123),
com.rabbitmq.client.impl.SocketFrameHandler.sendHeader(SocketFrameHandler.java:129),
com.rabbitmq.client.impl.SocketFrameHandler.sendHeader(SocketFrameHandler.java:134),
com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:277),
com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:678),
com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:722)
有趣的是,尽管在默认和受支持的 ssl 参数中设置了修改后的密码套件,但当我们记录受支持和默认的密码套件时,它也会显示其他所有不应该被允许的内容!我使用以下附加的 Java 命令行参数启动客户端:
-Dhttps.protocols=TLSv1.2
-Dhttps.cipherSuites=TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
-Ddeployment.security.TLSv1.2=true
-Ddeployment.security.TLSv1.1=false
-Ddeployment.security.SSLv3=false
另外,在启动客户端时,我记录了启用的和默认的密码套件。它显示了一整套密码套件,而不仅仅是我指定的那个。
有人可以帮我弄清楚如何解决这个问题吗?任何可以帮助我调试的指针都会非常有帮助。