1

编辑

通过一些实验,我注意到如果我将连接器更改为:

<amq:transportConnector name="ssl" uri="ssl://localhost:61617"/>

一切正常,所以我相信这个问题与我在使用 https 连接器时需要某种额外的配置有关。不幸的是,可用的信息包括http://activemq.apache.org/http-and-https-transports-reference.htmlhttp://docs.codehaus.org/display/JETTY/How%20to%20configure%20SSL。也许我错过了一个额外的步骤?

我已按照以下说明操作: http: //activemq.apache.org/how-do-i-use-ssl.html

我创建了一个证书,如下所示:

sudo keytool -keystore broker.ks -alias jetty -genkey -keyalg RSA

然后,我将 broker.ks 文件放在 Eclipse 中我的项目的类路径中。然后我有以下弹簧配置:

<beans 
xmlns="http://www.springframework.org/schema/beans" 
xmlns:amq="http://activemq.apache.org/schema/core"
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-3.1.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">


<amq:broker useJmx="false" persistent="false">
    <amq:persistenceAdapter>
            <amq:kahaDB />  
    </amq:persistenceAdapter>

    <!-- Configure ssl -->
    <amq:sslContext>
      <amq:sslContext keyStore="broker.ks" keyStorePassword="password"/>
    </amq:sslContext>

    <!-- Only allow connection through http -->
    <amq:transportConnectors>
            <amq:transportConnector name="https" uri="https://localhost:443"/>
    </amq:transportConnectors>

</amq:broker>

我的密钥库肯定在类路径上,并且密码肯定是我的密码和密钥的“密码”。但是,在运行应用程序时,系统会提示我:

org.eclipse.jetty.ssl.password

然后我输入“密码”,然后我会提示:

org.eclipse.jetty.ssl.keypassword

我再次输入“密码”并接收:

WARN : org.eclipse.jetty.util.log - FAILED SslSocketConnector@localhost:443: java.net.BindException: Permission denied
WARN : org.eclipse.jetty.util.log - FAILED org.eclipse.jetty.server.Server@225f1ae9: java.net.BindException: Permission denied
ERROR: org.apache.activemq.broker.BrokerService - Failed to start ActiveMQ JMS Message Broker. Reason: java.net.BindException: Permission denied
java.net.BindException: Permission denied
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:383)
at java.net.ServerSocket.bind(ServerSocket.java:328)
at java.net.ServerSocket.<init>(ServerSocket.java:194)
at javax.net.ssl.SSLServerSocket.<init>(SSLServerSocket.java:106)
at com.sun.net.ssl.internal.ssl.SSLServerSocketImpl.<init>(SSLServerSocketImpl.java:108)
at com.sun.net.ssl.internal.ssl.SSLServerSocketFactoryImpl.createServerSocket(SSLServerSocketFactoryImpl.java:72)
at org.eclipse.jetty.server.ssl.SslSocketConnector.newServerSocket(SslSocketConnector.java:378)
at org.eclipse.jetty.server.bio.SocketConnector.open(SocketConnector.java:75)
at org.eclipse.jetty.server.AbstractConnector.doStart(AbstractConnector.java:358)
at org.eclipse.jetty.server.bio.SocketConnector.doStart(SocketConnector.java:146)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
at org.eclipse.jetty.server.Server.doStart(Server.java:253)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
at org.apache.activemq.transport.http.HttpTransportServer.doStart(HttpTransportServer.java:119)
at org.apache.activemq.transport.https.HttpsTransportServer.doStart(HttpsTransportServer.java:66)
at org.apache.activemq.util.ServiceSupport.start(ServiceSupport.java:53)
at org.apache.activemq.broker.TransportConnector.start(TransportConnector.java:246)
at org.apache.activemq.broker.BrokerService.startTransportConnector(BrokerService.java:2162)
at org.apache.activemq.broker.BrokerService.startAllConnectors(BrokerService.java:2073)
at org.apache.activemq.broker.BrokerService.start(BrokerService.java:519)
at org.apache.activemq.xbean.XBeanBrokerService.afterPropertiesSet(XBeanBrokerService.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1536)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1409)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:574)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.apache.xbean.spring.context.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:161)
at org.apache.xbean.spring.context.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:51)
at com.bbconnecttxt.activeMq.Broker.main(Broker.java:7)

据我所知,根本不应该提示我输入密码。

4

1 回答 1

2

某些操作系统需要超级用户 (root) 权限才能将连接绑定到特权端口(低于 1024 的端口)。

以下消息基本上报告您正在尝试绑定到端口 443(这是一个特权端口),并且操作系统不允许您这样做:

WARN : org.eclipse.jetty.util.log - FAILED SslSocketConnector@localhost:443: java.net.BindException: Permission denied

尝试将 ActiveMQ 服务器的 HTTPS 配置为使用高于 1024 的端口进行 HTTPS,例如 8443。一般情况下,可以在 root 用户下运行 ActiveMQ(不推荐),或者使用类似authbind的工具,但重新配置端口应该是最容易改变的。

于 2012-04-24T17:04:39.027 回答