1

我已经在本地运行 Pulsar的 Ubuntu 18.04.2 LTS 上设置了 apache pulsar 独立 v2.3 。无需任何身份验证即可正常工作。我尝试使用security-tls-transportsecurity-tls-authentication配置 tls 证书。我已经修改了以下配置broker.confclient.confstandalone.conf按照链接中的说明进行了修改。使用命令运行 pulsarbin/pulsar standalone并使用以下命令发送消息。

bin/pulsar-client produce my-topic --messages "hello-pulsar"

但它会引发以下错误

 [pulsar-client-io-1-1] INFO  org.apache.pulsar.client.impl.ConnectionPool -           
 [[id: 0x8010c4f5, L:/127.0.0.1:42840 - R:localhost/127.0.0.1:6651]] 
 Connected to server
 09:47:17.686 [pulsar-client-io-1-1] WARN  
 org.apache.pulsar.client.impl.ClientCnx - Error during handshake
 java.nio.channels.ClosedChannelException: null
    at io.netty.handler.ssl.SslHandler.channelInactive(...)(Unknown Source) 
 ~[io.netty-netty-all-4.1.32.Final.jar:4.1.32.Final]
 09:47:17.691 [pulsar-client-io-1-1] INFO  
 org.apache.pulsar.client.impl.ClientCnx - [id: 0x8010c4f5, 
 L:/127.0.0.1:42840 ! R:localhost/127.0.0.1:6651] Disconnected
 09:47:17.692 [pulsar-client-io-1-1] WARN  
 org.apache.pulsar.client.impl.ConnectionPool - [[id: 0x8010c4f5, 
 L:/127.0.0.1:42840 ! R:localhost/127.0.0.1:6651]] Connection handshake 
 failed: org.apache.pulsar.client.api.PulsarClientException: Connection 
 already closed
 09:47:17.692 [pulsar-client-io-1-1] WARN  
 org.apache.pulsar.client.impl.PulsarClientImpl - [my-topic] Failed to get 
 partitioned topic metadata: 
 org.apache.pulsar.client.api.PulsarClientException: Connection already 
 closed
 09:47:17.692 [main] ERROR org.apache.pulsar.client.cli.PulsarClientTool - 
 Error while producing messages
 09:47:17.692 [main] ERROR org.apache.pulsar.client.cli.PulsarClientTool - 
 Connection already closed
 org.apache.pulsar.client.api.PulsarClientException: Connection already 
 closed at 
 org.apache.pulsar.client.impl.ClientCnx.channelInactive(ClientCnx.java:204) 
 ~[org.apache.pulsar-pulsar-client-original-2.3.0.jar:2.3.0]
    at 
 io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive
 (AbstractChannelHandlerContext.java:245) ~[io.netty-netty-all- 
 4.1.32.Final.jar:4.1.32.Final]
    at 
 io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive
(AbstractChannelHandlerContext.java:231) ~[io.netty-netty-all- 
4.1.32.Final.jar:4.1.32.Final]
    at 
io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive
(AbstractChannelHandlerContext.java:224) ~[io.netty-netty-all- 
4.1.32.Final.jar:4.1.32.Final]
    at 
io.netty.handler.codec.ByteToMessageDecoder.channelInputClosed
(ByteToMessageDecoder.java:390) ~[io.netty-netty-all- 
4.1.32.Final.jar:4.1.32.Final]
    at 
io.netty.handler.codec.ByteToMessageDecoder.channelInactive
   (ByteToMessageDecoder.java:355) ~[io.netty-netty-all- 
  4.1.32.Final.jar:4.1.32.Final]
    at 
  io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive
   (AbstractChannelHandlerContext.java:245) ~[io.netty-netty-all- 
  4.1.32.Final.jar:4.1.32.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive
  (AbstractChannelHandlerContext.java:231) ~[io.netty-netty-all- 
  4.1.32.Final.jar:4.1.32.Final]
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive
  (AbstractChannelHandlerContext.java:224) ~[io.netty-netty-all- 
 4.1.32.Final.jar:4.1.32.Final]
    at io.netty.handler.codec.ByteToMessageDecoder.channelInputClosed
 (ByteToMessageDecoder.java:390) ~[io.netty-netty-all- 
 4.1.32.Final.jar:4.1.32.Final]
    at io.netty.handler.codec.ByteToMessageDecoder.channelInactive
     (ByteToMessageDecoder.java:355) ~[io.netty-netty-all- 
  4.1.32.Final.jar:4.1.32.Final]
    at io.netty.handler.ssl.SslHandler.channelInactive(SslHandler.java:1054) 
 ~[io.netty-netty-all-4.1.32.Final.jar:4.1.32.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive
  (AbstractChannelHandlerContext.java:245) ~[io.netty-netty-all- 
4.1.32.Final.jar:4.1.32.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive
 (AbstractChannelHandlerContext.java:231) ~[io.netty-netty-all- 
4.1.32.Final.jar:4.1.32.Final]
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive
(AbstractChannelHandlerContext.java:224) ~[io.netty-netty-all- 
4.1.32.Final.jar:4.1.32.Final]
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelInactive
(DefaultChannelPipeline.java:1429) ~[io.netty-netty-all- 
4.1.32.Final.jar:4.1.32.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive
(AbstractChannelHandlerContext.java:245) ~[io.netty-netty-all- 
4.1.32.Final.jar:4.1.32.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive
(AbstractChannelHandlerContext.java:231) ~[io.netty-netty-all- 
4.1.32.Final.jar:4.1.32.Final]
    at io.netty.channel.DefaultChannelPipeline.fireChannelInactive
(DefaultChannelPipeline.java:947) ~[io.netty-netty-all- 
4.1.32.Final.jar:4.1.32.Final]
    at io.netty.channel.AbstractChannel$AbstractUnsafe$8.run
(AbstractChannel.java:826) ~[io.netty-netty-all- 
4.1.32.Final.jar:4.1.32.Final]
    at io.netty.util.concurrent.AbstractEventExecutor.safeExecute
(AbstractEventExecutor.java:163) ~[io.netty-netty-all- 
4.1.32.Final.jar:4.1.32.Final]
    at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks
(SingleThreadEventExecutor.java:404) ~[io.netty-netty-all- 
4.1.32.Final.jar:4.1.32.Final]
    at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:335) ~ 
[io.netty-netty-all-4.1.32.Final.jar:4.1.32.Final]
    at io.netty.util.concurrent.SingleThreadEventExecutor$5.run
(SingleThreadEventExecutor.java:909) ~[io.netty-netty-all- 
4.1.32.Final.jar:4.1.32.Final]
    at io.netty.util.concurrent.FastThreadLocalRunnable.run
(FastThreadLocalRunnable.java:30) ~[io.netty-netty-all- 
4.1.32.Final.jar:4.1.32.Final]
    at java.lang.Thread.run(Thread.java:748) ~[?:1.8.0_201]
09:47:17.694 [main] INFO  org.apache.pulsar.client.cli.PulsarClientTool - 0 
messages successfully produced

有人可以帮忙解决这个问题吗?

4

2 回答 2

0

启用 TLS 传输加密后,您需要将客户端配置为使用 https:// 和端口 8443 作为 Web 服务 URL,并使用 pulsar+ssl:// 和端口 6651 作为代理服务 URL。

看起来您使用的客户端 CLI 工具 bin/pulsar-client 生成 my-topic --messages "hello-pulsar",不使用 https+ssl:// 前缀。因此,您的客户端正在尝试建立非安全连接,并且在 TLS 协商步骤中失败,因为它。

您可以尝试使用指定 pulsar+ssl:// 前缀的简单 Java 或 Python 客户端进行连接吗?

于 2019-04-26T15:13:35.027 回答
0

如果您已在和中进行了所有必需的更改broker.conf,请尝试运行以下命令来发布数据:client.confstandalone.conf

bin/pulsar-client --url pulsar+ssl://127.0.0.1:6651 produce my-topic --messages "hello-pulsar"

在这里,您需要为 tls 数据指定服务 url。

确保您已将以下属性添加到您的standalone.conf文件中:

tlsEnabled=true
tlsCertificateFilePath=/path/to/broker.cert.pem
tlsKeyFilePath=/path/to/broker.key-pk8.pem
tlsTrustCertsFilePath=/path/to/ca.cert.pem
brokerServicePortTls=6651

此外,请确保更新client.conf文件中的以下配置值:

brokerServiceUrl=pulsar+ssl://127.0.0.1:6651
webServiceUrl=https://127.0.0.1:8443
tlsTrustCertsFilePath=/path/to/ca.cert.pem

这应该有效。

于 2020-06-15T12:54:14.363 回答