python mqtt tls_如何使用python在paho mqtt中使用ssl / tls我获得证书验证失败

hi I am working on IOT internet of things I am using paho MQTT I need to use SSL I wrote publish code using python I got an error in "certificate verify failed"

please help me thank in advance

MY PUBLISHING CODE

import time

import paho.mqtt.client as paho

import ssl

import certifi

#define callback

def on_message(client, userdata, message):

time.sleep(1)

print("received message =",str(message.payload.decode("utf-8")))

client= paho.Client("client-001")

client.on_message=on_message

print("connecting to broker ",)

client.tls_set("C:/Windows/system32/config/systemprofile/Desktop/attachments/server iot.crt", tls_version=ssl.PROTOCOL_TLSv1_2)

client.tls_insecure_set(True)

client.connect("iot.eclipse.org", 8883, 60)

def on_log(client, userdata, level, buf):

print("log: ",buf)#connect

client.loop_start() #start loop to process received messages

print("publishing ")

client.publish("$SYS/muthu","muthupavithran",)#publish

client.on_log=on_log

client.loop_forever()

#client.loop(100)

MY ERROR IS

connecting to broker

Traceback (most recent call last):

File "C:\Windows\system32\config\systemprofile\Desktop\attachments\publishTEST WITH LOG.py", line 14, in

client.connect("iot.eclipse.org", 8883, 60)

File "C:\Python34\lib\site-packages\paho\mqtt\client.py", line 768, in connect

return self.reconnect()

File "C:\Python34\lib\site-packages\paho\mqtt\client.py", line 927, in reconnect

sock.do_handshake()

File "C:\Python34\lib\ssl.py", line 810, in do_handshake

self._sslobj.do_handshake()

ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600)

MY CERTIFICATE IS

OpenSSL> s_client -showcerts -connect iot.eclipse.org:8883

CONNECTED(00000108)

depth=1 C = US, O = Let's Encrypt, CN = Let's Encry

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值