4

我正在使用 Java QPID 代理进行测试。我能够使用质子客户端发送和接收消息,但使用匿名身份验证。我有兴趣在启用身份验证的情况下进行测试,并了解质子客户端不支持(尚)。因此,我下载了 rabbitMQ 客户端 jar。我正在使用密码文件身份验证(QPID 附带)。

我像这样设置我的 RabbitMQ 客户端连接工厂:

    connectionFactory = new ConnectionFactory();
    connectionFactory.setHost("localhost");
    connectionFactory.setUsername("guest");
    connectionFactory.setPassword("guest");

代码在这一行失败(特别是在 getConnection 上)。

    connection = RabbitMQConnectionFactory.getInstance().getConnection();

这是一个例外:

java.io.IOException:未找到兼容的身份验证机制 - 服务器在 com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:309) 在 com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory) 提供 [CRAM-MD5] .java:590) 在 com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:612) 在 com.vue.rabbit.core.RabbitMQConnectionFactory.getConnection(RabbitMQConnectionFactory.java:37) 在 com.vue.rabbit.producer。 SimpleProducer.main(SimpleProducer.java:25)

如果我将 QPID 代理更改为使用匿名身份验证,并且还更改客户端不设置用户/密码,我会得到类似的异常“服务器提供 [ANONYMOUS]”

难道我做错了什么?这些应该兼容吗?有点不同的问题是,如果 Java 和 C++ QPID 代理都支持相同的在线 AMQP 协议,为什么会有它们?提前感谢您的帮助!

4

3 回答 3

5

实际上,最新的 QPID 支持纯 SASL,但不建议这样做。请参阅文档。在你的config.json包括类似的东西:"secureOnlyMechanisms": []如:

“身份验证提供者”:[{
    “id”:“798fc4a5-8edb-4b42-b1b2-8f7e9be8cccb”,
    “名称”:“密码文件”,
    "type" : "PlainPasswordFile",
    "路径" : "${qpid.home_dir}${file.separator}etc${file.separator}passwd",
    "secureOnlyMechanisms": [],
    “偏好提供者”:[{
      “id”:“1dcee789-be1b-49cc-9032-3bc4b974d1d6”,
      “名称”:“文件系统首选项”,
      “类型”:“文件系统首选项”,
      “路径”:“${qpid.work_dir}${file.separator}user.preferences.json”
    }]
于 2016-04-20T23:19:09.967 回答
1

What version of the Java Broker are you using?

If the answer is 0.30, the PlainPasswordFile/Base64MD5PasswordFile authentication providers (the former being the default in the shipped configuration) offer the PLAIN SASL mechanisms to clients only if they are using an AMQP port configured with SSL. This is done in order to prevent the password travelling in clear text over an unprotected port.

于 2014-10-17T08:23:06.530 回答
0

您可以通过设置此设置来解决此问题:

"secureOnlyMechanisms" : []

在 config.json 中的“authenticationproviders”下。此修复适用于 6.0.2 等旧版本。

因此,您的配置可以包含以下内容:

"authenticationproviders": [
    {
      "name": "plain",
      "type": "Plain",
      "users": [
        {
          "name": "guest",
          "type": "managed",
          "password": "guest"
        }
      ],
      "secureOnlyMechanisms" : []
    }
],

这在这里描述: https ://qpid.apache.org/releases/qpid-java-trunk/java-broker/book/Java-Broker-Security.html

于 2019-04-23T14:32:17.750 回答