程序问答   发布时间:2022-06-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了如何通过端口转发在 Internet 上部署带有 SSL 的 MQTT?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决如何通过端口转发在 Internet 上部署带有 SSL 的 MQTT??

开发过程中遇到如何通过端口转发在 Internet 上部署带有 SSL 的 MQTT?的问题如何解决?下面主要结合日常开发的经验,给出你关于如何通过端口转发在 Internet 上部署带有 SSL 的 MQTT?的解决方法建议,希望对你解决如何通过端口转发在 Internet 上部署带有 SSL 的 MQTT?有所启发或帮助;

我在 Internet 上使用 SSL 部署 MQTT 时遇到问题,但它在本地网络上运行良好。 这是场景:

  1. 我的 Eclipse MQTT 代理部署在客户端的机器上。机器在企业内网,不能上网。 假设它的本地 IP 地址是 10.125.22.103,名称是 Enterprise。 broker 正在使用 8883 端口。

  2. 客户端的外部 IP 地址为 222.111.112.109,并且正在使用端口转发将请求转发到部署机器。

  3. 我使用机器名称 Enterprise 作为通用名称,并使用此链接中的步骤生成证书文件

http://www.steves-internet-guide.com/mosquitto-tls/

我使用 KeyStore Explorer 在 .jks 文件中导入了 ca.crt 文件。

我在这个网址使用示例代码: https://github.com/eclipse/paho.mqtt.java/blob/master/org.eclipse.paho.sample.mqttv3app/src/main/java/org/eclipse/paho/sample/mqttv3app/Sample.java

  1. 在同一台机器上使用时,代理和客户端都能完美运行。

但是当我尝试通过 222.111.112.109:8883 从互联网连接到代理时,出现以下错误

2021-04-13 17:02:14:524 [ERROR] [MQTTListener_222.111.112.109:ID=28]:[MQTTListener.java:793] org.eclipse.paho.clIEnt.mqttv3.MqttException: MqttException
    at org.eclipse.paho.clIEnt.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:38)
    at org.eclipse.paho.clIEnt.mqttv3.internal.ClIEntComms$ConnectBG.run(ClIEntComms.java:736)
    at java.lang.Thread.run(UnkNown sourcE)
Caused by: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative names present
    at sun.security.ssl.Alerts.getSSLException(UnkNown sourcE)
    at sun.security.ssl.SSLSocketImpl.fatal(UnkNown sourcE)
    at sun.security.ssl.Handshaker.fatalSE(UnkNown sourcE)
    at sun.security.ssl.Handshaker.fatalSE(UnkNown sourcE)
    at sun.security.ssl.ClIEntHandshaker.serverCertificate(UnkNown sourcE)
    at sun.security.ssl.ClIEntHandshaker.processmessage(UnkNown sourcE)
    at sun.security.ssl.Handshaker.processLoop(UnkNown sourcE)
    at sun.security.ssl.Handshaker.process_record(UnkNown sourcE)
    at sun.security.ssl.SSLSocketImpl.readRecord(UnkNown sourcE)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(UnkNown sourcE)
    at sun.security.ssl.SSLSocketImpl.startHandshake(UnkNown sourcE)
    at sun.security.ssl.SSLSocketImpl.startHandshake(UnkNown sourcE)
    at org.eclipse.paho.clIEnt.mqttv3.internal.SSLNetworkmodule.start(SSLNetworkmodule.java:149)
    at org.eclipse.paho.clIEnt.mqttv3.internal.ClIEntComms$ConnectBG.run(ClIEntComms.java:722)
    at java.lang.Thread.run(UnkNown sourcE)
Caused by: java.security.cert.CertificateException: No subject alternative names present
    at sun.security.util.Hostnamechecker.matchIP(UnkNown sourcE)
    at sun.security.util.Hostnamechecker.match(UnkNown sourcE)
    at sun.security.ssl.x509trustmanagerImpl.checkIDentity(UnkNown sourcE)
    at sun.security.ssl.x509trustmanagerImpl.checkIDentity(UnkNown sourcE)
    at sun.security.ssl.x509trustmanagerImpl.checkTrusted(UnkNown sourcE)
    at sun.security.ssl.x509trustmanagerImpl.checkServerTrusted(UnkNown sourcE)
    at sun.security.ssl.ClIEntHandshaker.serverCertificate(UnkNown sourcE)
    at sun.security.ssl.ClIEntHandshaker.processmessage(UnkNown sourcE)
    at sun.security.ssl.Handshaker.processLoop(UnkNown sourcE)
    at sun.security.ssl.Handshaker.process_record(UnkNown sourcE)
    at sun.security.ssl.SSLSocketImpl.readRecord(UnkNown sourcE)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(UnkNown sourcE)
    at sun.security.ssl.SSLSocketImpl.startHandshake(UnkNown sourcE)
    at sun.security.ssl.SSLSocketImpl.startHandshake(UnkNown sourcE)
    at org.eclipse.paho.clIEnt.mqttv3.internal.SSLNetworkmodule.start(SSLNetworkmodule.java:149)
    at org.eclipse.paho.clIEnt.mqttv3.internal.ClIEntComms$ConnectBG.run(ClIEntComms.java:722)
    at java.lang.Thread.run(UnkNown sourcE)

我该如何解决这个错误?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

大佬总结

以上是大佬教程为你收集整理的如何通过端口转发在 Internet 上部署带有 SSL 的 MQTT?全部内容,希望文章能够帮你解决如何通过端口转发在 Internet 上部署带有 SSL 的 MQTT?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: