【问题标题】:encrypted password doesn't work in activemq加密密码在activemq中不起作用
【发布时间】:2016-10-24 22:37:16
【问题描述】:

我正在尝试加密用于建立和连接到 activemq 队列的密码。我正在跟进HERE 的步骤,我可以使用新的activemq-security.xml 文件启动activemq。我有一个脚本尝试创建并连接到队列,但我不断收到用户名或密码无效的错误。

我加密了消费者用户的密码并将加密后的密码存储在 credentials-enc.properties 文件中,例如:

consumer.password=ENC(awknernfjewnwk)

我尝试了不同的方法,但我确信凭据-enc.properties 出于某种原因没有被拾取,这是它的定义方式:

        <beans
          xmlns="http://www.springframework.org/schema/beans"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
          http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">

        <bean id="environmentVariablesConfiguration" class="org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig">
          <property name="algorithm" value="PBEWithMD5AndDES" />
          <property name="passwordEnvName" value="ACTIVEMQ_ENCRYPTION_PASSWORD" />
        </bean>

        <bean id="configurationEncryptor" class="org.jasypt.encryption.pbe.StandardPBEStringEncryptor">
          <property name="config" ref="environmentVariablesConfiguration" />
        </bean>

        <bean id="propertyConfigurer" class="org.jasypt.spring31.properties.EncryptablePropertyPlaceholderConfigurer">
          <constructor-arg ref="configurationEncryptor" />
          <property name="location" value="file:${activemq.base}/conf/credentials-enc.properties"/>
        </bean>

   <!-- Allows accessing the server log -->
    <bean id="logQuery" class="io.fabric8.insight.log.log4j.Log4jLogQuery"
          lazy-init="false" scope="singleton"
          init-method="start" destroy-method="stop">
    </bean>

    <!--
        The <broker> element is used to configure the ActiveMQ broker.
    -->
    <broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" advisorySupport="false" dataDirectory="${activemq.data}">
        <plugins>
             <simpleAuthenticationPlugin>
                    <users>
                        <authenticationUser username="admin" password="admin"
                            groups="admins"/>
                        <authenticationUser username="consumer" password="$(consumer.password)"
                            groups="readers"/>
                        <authenticationUser username="producer" password="$(producer.password)"
                            groups="writers"/>
                    </users>
                </simpleAuthenticationPlugin>
              <authorizationPlugin>
               <map>
                <authorizationMap>
                   <authorizationEntries>
                     <authorizationEntry queue=">" read="readers" write="admins" admin="admins" />
                     <authorizationEntry queue="CLIMATE" read="readers" write="writers" admin="admins" />
                     <authorizationEntry topic=">" read="admins,readers" write="admins,writers" admin="admins" />
                   </authorizationEntries>
                   <tempDestinationAuthorizationEntry>
                     <tempDestinationAuthorizationEntry read="admins" write="admins" admin="admins"/>
                   </tempDestinationAuthorizationEntry>
                </authorizationMap>
              </map>
           </authorizationPlugin>
          </plugins>
        <destinationPolicy>
            <policyMap>
              <policyEntries>
                <policyEntry topic=">" >
                    <!-- The constantPendingMessageLimitStrategy is used to prevent
                         slow topic consumers to block producers and affect other consumers
                         by limiting the number of messages that are retained
                         For more information, see:

                         http://activemq.apache.org/slow-consumer-handling.html

                    -->
                  <pendingMessageLimitStrategy>
                    <constantPendingMessageLimitStrategy limit="1000"/>
                  </pendingMessageLimitStrategy>
                </policyEntry>
              </policyEntries>
            </policyMap>
        </destinationPolicy>

下面是我得到的错误日志的图像:

传输连接器配置

<transportConnectors>
    <!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
    <transportConnector name="openwire" uri="tcp://0.0.0.0:61617?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
</transportConnectors>

任何想法可能是什么原因?

提前致谢!

【问题讨论】:

    标签: encryption activemq


    【解决方案1】:

    问题其实很简单,你用for变量$(producer.password)但是错了,你需要${producer.password}!!

    就是这样。

    请注意,必须创建队列“CLIMATE”,因为用户“consumer”不在 admins 组中,无法创建。

    【讨论】:

    • 感谢哈森的回复!是的,我使用了ACTIVEMQ_ENCRYPTION_PASSWORD=activemq 我也尝试在配置文件中提供activemq 作为属性。我提供的消费者加密只是一个示例,而不是我在加密后得到的实际结果,我很确定指定 credentials-enc.properties 的位置属性没有被拾取,因为我尝试在没有加密的情况下使用它并且它再次失败。 Stopping tcp://XXXX because Failed with SecurityException: User name [consumer] or password is invalid. | org.apache.activemq.broker.TransportConnection | ActiveMQ BrokerServic
    • 您可以重命名 credentials-enc.properties 以测试在代理启动时您是否会遇到 FileNotFoundException
    • Hassen,我尝试重命名凭据文件,但正如您所料,我遇到了未找到文件的异常。我正在使用最新的 AMQ 版本 5.14.1,我还在上面的问题中附加了我的日志副本。 (删除了一些与我的系统相关的数据并突出显示了 AMQ 尝试连接的 tcp 连接,我想知道为什么它有 :34635@61617 我使用的是端口 61617 而不是默认的 61616 btw?
    • 看来 tcp 配置为使用 61617 ,你说的 tcp connection AMQ 试图连接 是什么意思?你有经纪人网络吗?您可以发布 transportConnectors 配置吗,在您的启动日志中,您可以验证 tcp 端口是否以类似这样的方式启动 ** INFO |连接器 tcp://localhost:61616 已启动 | org.apache.activemq.broker.TransportConnector **
    • 嗨,哈桑,我将 tcp 配置为使用 61617,但我没有代理网络。我的意思是我的问题是上面日志图像中突出显示的行显示了正确的 tcp 连接,但例如在 @61617 之前有 34635 我想知道这个数字代表什么(34635)?在上面添加了传输连接器配置
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-11-28
    • 2018-11-22
    • 2017-11-10
    • 1970-01-01
    • 1970-01-01
    • 2016-11-07
    • 2021-02-22
    相关资源
    最近更新 更多