简体   繁体   English

树莓派的 MQTT 问题,SSL:UNSUPPORTED_PROTOCOL] 不受支持的协议 (_ssl.c:1056)

[英]MQTT problem with raspberry pi, SSL: UNSUPPORTED_PROTOCOL] unsupported protocol (_ssl.c:1056)

I am running an MQTT broker on an AWS server which functions as normal on mac and windows devices does not function as expected on my raspberry pi.我在 AWS 服务器上运行 MQTT 代理,该服务器在 mac 上正常运行,而 windows 设备在我的树莓派上没有按预期运行。 My subscriber and publisher code works and has been tested on multiple operating systems.我的订阅者和发布者代码有效并且已经在多个操作系统上进行了测试。 I believe the issue is with my raspberry pi settings however I am unable to resolve this.我相信问题出在我的树莓派设置上,但是我无法解决这个问题。

The error I am receiving (with python3):我收到的错误(使用 python3):

pi@raspberrypi:~/MQTT $ sudo python3 subscriber.py 
Traceback (most recent call last):
  File "subscriber.py", line 42, in <module>
    client.connect(brokerAddress,port,60)
  File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 937, in connect
    return self.reconnect()
  File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 1100, in reconnect
    sock.do_handshake()
  File "/usr/lib/python3.7/ssl.py", line 1117, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: UNSUPPORTED_PROTOCOL] unsupported protocol (_ssl.c:1056)

The error I am receiving with python,我用 python 收到的错误,

pi@raspberrypi:~/MQTT $ python subscriber.py 
Traceback (most recent call last):
  File "subscriber.py", line 42, in <module>
    client.connect(brokerAddress,port,60)
  File "/home/pi/.local/lib/python2.7/site-packages/paho/mqtt/client.py", line 937, in connect
    return self.reconnect()
  File "/home/pi/.local/lib/python2.7/site-packages/paho/mqtt/client.py", line 1100, in reconnect
    sock.do_handshake()
  File "/usr/lib/python2.7/ssl.py", line 828, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: UNSUPPORTED_PROTOCOL] unsupported protocol (_ssl.c:727)

I have tried several things including using python vs python3, ensuring latest versions of paho is installed, rebooting, running the raspberry pi on another network, running as sudo, and some other things too.我尝试了几件事,包括使用 python 与 python3,确保安装了最新版本的 paho,重新启动,在另一个网络上运行 raspberry pi,作为 sudo 运行,以及其他一些事情。

This may be unrelated but I have had issues trying to run git clone before on this raspberry pi, and i think it may be related to ssl issues.这可能无关,但我之前在这个树莓派上尝试运行 git clone 时遇到了问题,我认为这可能与 ssl 问题有关。

Other potentially useful things其他可能有用的东西

pi@raspberrypi:~/MQTT $ openssl version
OpenSSL 1.1.1d  10 Sep 2019

the code, subscriber.py:代码,subscriber.py:

import paho.mqtt.client as mqtt
import sys
import time
import ssl

# The callback for when the client receives a conack response from the server.
def on_connect(client, userdata, flags, rc):
    print("Connected with result code "+str(rc))
    client.subscribe("test")
    printf("subscribed to test")

# When a message is received
def on_message(client, userdata, msg):
    print("INCOMING") #begin message
    print("TOPIC: \t\t"+msg.topic+"\nMESSAGE:\t"+str(msg.payload.decode()))

client = mqtt.Client("C1")
#declare loc of tls certificate
client.tls_set('/home/pi/MQTT/ca.crt',cert_reqs=ssl.CERT_NONE)

client.tls_insecure_set(True)
client.on_connect = on_connect
client.on_message = on_message

#plain text credentials
client.username_pw_set("myusername","mypassword")

#declare address and port
brokerAddress="my-ipv4-ip-address"
port=8883
client.connect(brokerAddress,port,60)
#continuous loop
client.loop_forever()

This exact code when run on my mac works, I can publish this message from my desktop (windows) and it displays as expected.这个确切的代码在我的 mac 上运行时,我可以从我的桌面(windows)发布这个消息,它按预期显示。 来自 mac 的截图

Please do let me know if there is any other information you need from me to help troubleshoot.如果您需要我提供任何其他信息来帮助排除故障,请告诉我。

I experienced the same issue.我遇到了同样的问题。
The certificate I generated where TLSv1.0 certificates.我生成的证书在哪里 TLSv1.0 证书。 but these are by default not accepted by the RPi's openssl config.但是这些默认情况下不被 RPi 的 openssl 配置接受。
I solved this by changing the minimum accepted protocol version from v1.2 to v1.0我通过将可接受的最低协议版本从 v1.2 更改为 v1.0 解决了这个问题

in /etc/ssl/openssl.cnf/etc/ssl/openssl.cnf
changed MinProtocol = TLSv1.2 to MinProtocol = TLSv1.0MinProtocol = TLSv1.2更改为MinProtocol = TLSv1.0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 python ssl ssl.SSLError: [SSL: UNSUPPORTED_PROTOCOL] 不支持的协议 (_ssl.c:590) - python ssl ssl.SSLError: [SSL: UNSUPPORTED_PROTOCOL] unsupported protocol (_ssl.c:590) ssl.SSLError: [SSL: UNSUPPORTED_PROTOCOL] 不支持的协议 (_ssl.c:1108) - ssl.SSLError: [SSL: UNSUPPORTED_PROTOCOL] unsupported protocol (_ssl.c:1108) ssl.SSLError: [SSL: UNSUPPORTED_PROTOCOL] 在 Docker Python:3.6-slim 中不受支持的协议 (_ssl.c:852) - ssl.SSLError: [SSL: UNSUPPORTED_PROTOCOL] unsupported protocol (_ssl.c:852) in Docker Python:3.6-slim SMTP_SSL SSLError:[SSL:UNKNOWN_PROTOCOL]未知协议(_ssl.c:590) - SMTP_SSL SSLError: [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:590) 中止:错误:发生了违反协议的EOF(_ssl.c:590) - abort: error: EOF occurred in violation of protocol (_ssl.c:590) Mysql 连接器 python 错误违反协议 (_ssl.c:2483) - Mysql connector python error violation of protocol (_ssl.c:2483) 邮件失败; [SSL:UNKNOWN_PROTOCOL]未知协议(_ssl.c:645) - mail failed; [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:645) 发生Pushbullet和EOF违反协议的情况(_ssl.c:590) - Pushbullet and EOF occurred in violation of protocol (_ssl.c:590) Python Speedtest面临认证问题_ssl.c:1056 - Python Speedtest facing problems with certification _ssl.c:1056 请求ssl.SSLEOFError:EOF违反协议(_ssl.c:777) - Requests ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:777)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM