mock-server / mockserver

MockServer enables easy mocking of any system you integrate with via HTTP or HTTPS with clients written in Java, JavaScript and Ruby. MockServer also includes a proxy that introspects all proxied traffic including encrypted SSL traffic and supports Port Forwarding, Web Proxying (i.e. HTTP proxy), HTTPS Tunneling Proxying (using HTTP CONNECT) and SOCKS Proxying (i.e. dynamic port forwarding).
http://mock-server.com
Apache License 2.0
4.61k stars 1.08k forks source link

under jdk17, meet javax.security.cert.CertificateException: Could not find class: java.lang.ClassNotFoundException: com/sun/security/cert/internal/x509/X509V1CertImpl #1739

Open yqzhan opened 1 year ago

yqzhan commented 1 year ago

Describe the issue under jdk17, meet javax.security.cert.CertificateException: Could not find class: java.lang.ClassNotFoundException: com/sun/security/cert/internal/x509/X509V1CertImpl

What you are trying to do try upgrade jdk8 to jdk17

MockServer version

org.mock-server mockserver-netty-no-dependencies 5.15.0 test org.mock-server mockserver-client-java-no-dependencies 5.15.0 test

To Reproduce Steps to reproduce the issue:

  1. How you are running MockServer (i.e maven plugin, docker, etc) junit
  2. Code you used to create expectations send https request to mock server
  3. What error you saw javax.security.cert.CertificateException: Could not find class: java.lang.ClassNotFoundException: com/sun/security/cert/internal/x509/X509V1CertImpl Expected behaviour no error

MockServer Log

2023-05-12 10:33:53,243+08:00:INFO[MockServer-EventLog90]o.m.l.MockServerEventLog:119-->1080 exception decoding client certificate java.lang.IllegalStateException: javax.security.cert.CertificateException: Could not find class: java.lang.ClassNotFoundException: com/sun/security/cert/internal/x509/X509V1CertImpl at shaded_package.io.netty.handler.ssl.util.LazyJavaxX509Certificate.unwrap(LazyJavaxX509Certificate.java:142) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.handler.ssl.util.LazyJavaxX509Certificate.getSerialNumber(LazyJavaxX509Certificate.java:61) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at org.mockserver.mappers.JDKCertificateToMockServerX509Certificate.lambda$setClientCertificates$0(JDKCertificateToMockServerX509Certificate.java:34) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:273) ~[?:?] at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992) ~[?:?] at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) ~[?:?] at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) ~[?:?] at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921) ~[?:?] at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:?] at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682) ~[?:?] at org.mockserver.mappers.JDKCertificateToMockServerX509Certificate.setClientCertificates(JDKCertificateToMockServerX509Certificate.java:54) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at org.mockserver.mappers.FullHttpRequestToMockServerHttpRequest.mapFullHttpRequestToMockServerRequest(FullHttpRequestToMockServerHttpRequest.java:74) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at org.mockserver.codec.NettyHttpToMockServerHttpRequestDecoder.decode(NettyHttpToMockServerHttpRequestDecoder.java:40) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at org.mockserver.codec.NettyHttpToMockServerHttpRequestDecoder.decode(NettyHttpToMockServerHttpRequestDecoder.java:20) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:88) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at org.mockserver.dashboard.DashboardWebSocketHandler.channelRead(DashboardWebSocketHandler.java:137) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at org.mockserver.netty.websocketregistry.CallbackWebSocketServerHandler.channelRead(CallbackWebSocketServerHandler.java:57) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.handler.codec.http2.InboundHttp2ToHttpAdapter.fireChannelRead(InboundHttp2ToHttpAdapter.java:133) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.handler.codec.http2.InboundHttp2ToHttpAdapter.onDataRead(InboundHttp2ToHttpAdapter.java:245) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.handler.codec.http2.DelegatingDecompressorFrameListener.onDataRead(DelegatingDecompressorFrameListener.java:82) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.handler.codec.http2.Http2FrameListenerDecorator.onDataRead(Http2FrameListenerDecorator.java:36) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.handler.codec.http2.Http2EmptyDataFrameListener.onDataRead(Http2EmptyDataFrameListener.java:49) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder$FrameReadListener.onDataRead(DefaultHttp2ConnectionDecoder.java:307) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.handler.codec.http2.DefaultHttp2FrameReader.readDataFrame(DefaultHttp2FrameReader.java:415) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.handler.codec.http2.DefaultHttp2FrameReader.processPayloadState(DefaultHttp2FrameReader.java:250) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.handler.codec.http2.DefaultHttp2FrameReader.readFrame(DefaultHttp2FrameReader.java:159) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder.decodeFrame(DefaultHttp2ConnectionDecoder.java:173) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.handler.codec.http2.DecoratingHttp2ConnectionDecoder.decodeFrame(DecoratingHttp2ConnectionDecoder.java:63) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.handler.codec.http2.Http2ConnectionHandler$FrameDecoder.decode(Http2ConnectionHandler.java:393) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.handler.codec.http2.Http2ConnectionHandler.decode(Http2ConnectionHandler.java:453) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:529) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:468) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:290) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1373) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1236) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1285) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:529) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:468) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:290) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at shaded_package.io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] at java.lang.Thread.run(Thread.java:833) ~[?:?] Caused by: javax.security.cert.CertificateException: Could not find class: java.lang.ClassNotFoundException: com/sun/security/cert/internal/x509/X509V1CertImpl at javax.security.cert.X509Certificate.getInst(X509Certificate.java:242) ~[?:?] at javax.security.cert.X509Certificate.getInstance(X509Certificate.java:208) ~[?:?] at shaded_package.io.netty.handler.ssl.util.LazyJavaxX509Certificate.unwrap(LazyJavaxX509Certificate.java:140) ~[mockserver-netty-no-dependencies-5.15.0.jar:5.15.0] ... 66 more

ryanzhutao commented 1 year ago

@yqzhan did you find any workaround?

baseballyama commented 1 year ago

I think this is fixed by this commit. But it's not included to released version.

https://github.com/mock-server/mockserver/pull/1657/commits/08f51f365162a11204347495302ab522f5f3cf96

pavilalopes commented 1 year ago

I'm getting the same error when I try to use client certificates (mTLS)

@baseballyama That commit is not tied to any PR or branch in this repo. How did you find it?

baseballyama commented 1 year ago

@pavilalopes

Ohh I don't remember how to find this commit. (I think I'd looked for PRs.)

But again I checked commits on master branch and I think this commit could be fix this issue. https://github.com/mock-server/mockserver/commit/618d937434010c26d0d56169d296c183c0574282

pavilalopes commented 1 year ago

I compiled the latest version from git and this bug is indeed fixed.

sebagomez commented 1 year ago

Can we get this fix planed for a minor bug fix upgrade please?

stukalin commented 8 months ago

Huge +1 here

prary commented 4 months ago

Can we get this fix planed for a minor bug fix upgrade please?

This change is already part of latest master

baseballyama commented 4 months ago

This change is already part of latest master

But not released yet.

durcon commented 2 weeks ago

Is there any relase date for this fix?