isminexxb opened a new issue, #17540:
URL: https://github.com/apache/pulsar/issues/17540

   ### Search before asking
   
   - [X] I searched in the [issues](https://github.com/apache/pulsar/issues) 
and found nothing similar.
   
   
   ### Version
   
   server: v2.10.0
   client: c++
   
   ### Minimal reproduce step
   
   1. We already have an internal cluster without any auth mechanism. 
   
   2. Now we need to open the cluster to external services. Considering that 
existing internal clients connect to the cluster without any verification, we 
try to add proxy service for external verification. We configure the proxy with 
zk url instead of broker url.
   
   3. At first, we follow the guide 
(https://pulsar.apache.org/docs/next/security-tls-transport) to configure the 
proxy for TLS encryption, it works as expected.
   
   4. Then, we follow the guide 
(https://pulsar.apache.org/docs/next/security-jwt) to configure the proxy for 
JWT, the proxy throws exception as follows and close the client connection.
   2022-09-08T15:42:39,307+0800 [pulsar-proxy-io-2-11] INFO  
org.apache.pulsar.proxy.server.ProxyConnection - [/127.0.0.1:48159] New 
connection opened
   2022-09-08T15:42:39,311+0800 [pulsar-proxy-io-2-11] WARN  
io.netty.channel.DefaultChannelPipeline - An exceptionCaught() event was fired, 
and it reached at the tail of the pipeline. It usually means the last handler 
in the pipeline did not handle the exception.
   io.netty.handler.codec.DecoderException: 
javax.net.ssl.SSLHandshakeException: error:100000c0:SSL 
routines:OPENSSL_internal:PEER_DID_NOT_RETURN_A_CERTIFICATE
           at 
io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:480)
 ~[io.netty-netty-codec-4.1.74.Final.jar:4.1.74.Final]
           at 
io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:279)
 ~[io.netty-netty-codec-4.1.74.Final.jar:4.1.74.Final]
           at 
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
 [io.netty-netty-transport-4.1.74.Final.jar:4.1.74.Final]
           at 
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
 [io.netty-netty-transport-4.1.74.Final.jar:4.1.74.Final]
           at 
io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
 [io.netty-netty-transport-4.1.74.Final.jar:4.1.74.Final]
           at 
io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
 [io.netty-netty-transport-4.1.74.Final.jar:4.1.74.Final]
           at 
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
 [io.netty-netty-transport-4.1.74.Final.jar:4.1.74.Final]
           at 
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
 [io.netty-netty-transport-4.1.74.Final.jar:4.1.74.Final]
           at 
io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
 [io.netty-netty-transport-4.1.74.Final.jar:4.1.74.Final]
           at 
io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:795)
 [io.netty-netty-transport-classes-epoll-4.1.74.Final.jar:4.1.74.Final]
           at 
io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:480) 
[io.netty-netty-transport-classes-epoll-4.1.74.Final.jar:4.1.74.Final]
           at 
io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:378) 
[io.netty-netty-transport-classes-epoll-4.1.74.Final.jar:4.1.74.Final]
           at 
io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
 [io.netty-netty-common-4.1.74.Final.jar:4.1.74.Final]
           at 
io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) 
[io.netty-netty-common-4.1.74.Final.jar:4.1.74.Final]
           at 
io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
 [io.netty-netty-common-4.1.74.Final.jar:4.1.74.Final]
           at java.lang.Thread.run(Thread.java:748) [?:1.8.0_242]
   Caused by: javax.net.ssl.SSLHandshakeException: error:100000c0:SSL 
routines:OPENSSL_internal:PEER_DID_NOT_RETURN_A_CERTIFICATE
           at 
io.netty.handler.ssl.ReferenceCountedOpenSslEngine.needWrapAgain(ReferenceCountedOpenSslEngine.java:1343)
 ~[io.netty-netty-handler-4.1.74.Final.jar:4.1.74.Final]
           at 
io.netty.handler.ssl.ReferenceCountedOpenSslEngine.sslReadErrorResult(ReferenceCountedOpenSslEngine.java:1360)
 ~[io.netty-netty-handler-4.1.74.Final.jar:4.1.74.Final]
           at 
io.netty.handler.ssl.ReferenceCountedOpenSslEngine.unwrap(ReferenceCountedOpenSslEngine.java:1305)
 ~[io.netty-netty-handler-4.1.74.Final.jar:4.1.74.Final]
           at 
io.netty.handler.ssl.ReferenceCountedOpenSslEngine.unwrap(ReferenceCountedOpenSslEngine.java:1392)
 ~[io.netty-netty-handler-4.1.74.Final.jar:4.1.74.Final]
           at 
io.netty.handler.ssl.ReferenceCountedOpenSslEngine.unwrap(ReferenceCountedOpenSslEngine.java:1435)
 ~[io.netty-netty-handler-4.1.74.Final.jar:4.1.74.Final]
           at 
io.netty.handler.ssl.SslHandler$SslEngineType$1.unwrap(SslHandler.java:221) 
~[io.netty-netty-handler-4.1.74.Final.jar:4.1.74.Final]
           at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1342) 
~[io.netty-netty-handler-4.1.74.Final.jar:4.1.74.Final]
           at 
io.netty.handler.ssl.SslHandler.decodeNonJdkCompatible(SslHandler.java:1246) 
~[io.netty-netty-handler-4.1.74.Final.jar:4.1.74.Final]
           at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1286) 
~[io.netty-netty-handler-4.1.74.Final.jar:4.1.74.Final]
           at 
io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:510)
 ~[io.netty-netty-codec-4.1.74.Final.jar:4.1.74.Final]
           at 
io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:449)
 ~[io.netty-netty-codec-4.1.74.Final.jar:4.1.74.Final]
           ... 15 more
   2022-09-08T15:42:39,311+0800 [pulsar-proxy-io-2-11] WARN  
org.apache.pulsar.proxy.server.ProxyConnection - [/127.0.0.1:48159] Got 
exception DecoderException : javax.net.ssl.SSLHandshakeException: 
error:100000c0:SSL routines:OPENSSL_internal:PEER_DID_NOT_RETURN_A_CERTIFICATE 
io.netty.handler.codec.DecoderException: javax.net.ssl.SSLHandshakeException: 
error:100000c0:SSL routines:OPENSSL_internal:PEER_DID_NOT_RETURN_A_CERTIFICATE
   2022-09-08T15:42:39,311+0800 [pulsar-proxy-io-2-11] INFO  
org.apache.pulsar.proxy.server.ProxyConnection - [/127.0.0.1:48159] Connection 
closed
   
   5. After analysis, we realize that both TLS encryption and JWT require the 
client to use "setAuth()" method to set authentication method. Does it mean 
that JWT cannot work on top of TLS encryption?
   
   6. At last, We abandon the TLS encryption and test with JWT only. JWT 
authentication works as expected.
   
   7. But JWT authorization does not work. Client can produce message to the 
topic even it is not granted the privilege. We review the implemention of proxy 
service(/pulsar/pulsar-proxy), no authorization check was found. 
   
   
   ### What did you expect to see?
   
   1. JWT works well with TLS encryption.
   2. JWT authorization works well with proxy service only.
   
   ### What did you see instead?
   
   Exception occurres or JWT authorization does not work.
   
   ### Anything else?
   
   _No response_
   
   ### Are you willing to submit a PR?
   
   - [ ] I'm willing to submit a PR!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to