ssl.SSLContext
invalid cert
#17405
-
Before initializing a MQTT Client I initialize an from umqtt.simple import MQTTClient
import ssl
def mqtt_connect():
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
ssl_context.load_verify_locations(cafile="./ca.crt")
ssl_context.load_cert_chain(certfile="./client.crt", keyfile="./client.key")
client = MQTTClient(
client_id="test_id",
server="192.168.68.99",
port=8883,
keepalive=60,
ssl=ssl_context,
)
client.connect()
print(f"Connected to MQTT Broker {SERVER}")
return client I'm not sure what I am doing wrong, because:
So the cert-files aren't invalid per se but they are seen as invalid by the MicroPython ssl/tls module. Are there specific requirements in place regarding the type of certificates I can use? For what it's worth I'll also share the commands I used to generate the certificates: # CA
openssl req -new -x509 -days 365 -extensions v3_ca -keyout ca.key -out ca.crt
# CLIENT
openssl genrsa -out client.key 2048
openssl req -new -out client.csr -key client.key
openssl x509 -req -in client.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out client.crt -days 360 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
@HendrikThePendric Also some resources that may help: |
Beta Was this translation helpful? Give feedback.
@HendrikThePendric
see official docs https://docs.micropython.org/en/latest/library/ssl.html
TLDR: use DER format
Also some resources that may help: