性能常识 求助贴 Jmeter 报错

高明 · 2024年05月28日 · 最后由 高明 回复于 2024年05月29日 · 4231 次阅读

背景:公司目前要适配 TCP 通道加密,使用到了腾讯的 kona。
场景 1:手写一个 TCP 取样器,修改了 TCPSample 源码创建 socket 的方式,改为返回 sslSocket。进行 tcp 取样器测试
结果:报错 javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate),能看到尝试建立过握手但是失败(排除证书问题,证书是没问题的,创建 socket 的方式在代码中测试通过)
场景 2:下载 jmeter5.6 源码,添加 gradle 依赖,测试运行
结果:Cause: cannot recognise keyAlgorithm: 22,按照网上的搜索结果结果过,无效

共收到 7 条回复 时间 点赞

嗯,我知道了

# For the first scenario, the error javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate) indicates that there might be an issue with the SSL/TLS protocol or cipher suites being used. You can try specifying the SSL context and enabling specific protocols and cipher suites. Here's an example of how you can modify your code to specify the SSL context with specific protocols and cipher suites:

# Add the following code snippet to your TCPSample code where you create the SSL socket:
# This example enables TLSv1.2 and specifies some common cipher suites, you can adjust them based on your requirements.

# Make sure to import necessary classes:
# import javax.net.ssl.SSLContext;
# import javax.net.ssl.SSLSocketFactory;
# import javax.net.ssl.SSLSocket;

SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
sslContext.init(null, null, null);

SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();
SSLSocket sslSocket = (SSLSocket) sslSocketFactory.createSocket("{{host}}", {{port}});
sslSocket.setEnabledProtocols(new String[] {"TLSv1.2"});
sslSocket.setEnabledCipherSuites(new String[] {"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384"});

# Test your TCPSample with these modifications to see if the SSL handshake issue is resolved.

# For the second scenario, the error Cause: cannot recognise keyAlgorithm: 22 in JMeter might be related to the version compatibility of the JDK used with JMeter. You can try updating your JDK version or ensuring that the JDK version is compatible with JMeter. Additionally, make sure that the gradle dependencies you added are correct and compatible with JMeter 5.6.

# If the issue persists, you can try checking the JMeter logs for more detailed error messages or consult the JMeter documentation for troubleshooting this specific error.

simonpatrick 回复

"TLCPv1.1" 是中国的加密协议,主要在中国使用。
"TLSv1.2" 是国际上广泛使用的加密协议。
两种不一致我是第一个

场景 1: 看看 jmeter 配置文件中 ssl 相关配置打开了没
场景 2: 源码可以使用 5.4.1 版本,我本地就是这个版本,高版本的坑比较多,网上也没资料

jdk 用高版本试试,如 11

chenhongjian 回复

jmeter 配置文件都是 https.ssl 我这个是 tcp 取样器,并且我也配置了。我也改了 jdk 的安全策略。
创建 socket 的方式代码一样的 我要是 java 项目中调用就能正常使用,只要是 jmeter 中使用就有问题

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册