wanghaEMQ / pynng-mqtt

MIT License
9 stars 3 forks source link

mqtt_quic tls configuration #3

Open Dawn369 opened 1 year ago

Dawn369 commented 1 year ago

HI! Can you give a mqtt_quic client demo it support TLS? Thanks!

Dawn369 commented 1 year ago

def quic_mqtt_client(client_id): print(f"set tls cert") f0 = open(r"./cert/ca/trust_chain.pem", 'rt') f1 = open(r"./cert/client/tls_lion_cert.pem", "rt") f2 = open(r"./cert/client/tls_lion_priv_key.pem", "rt") tls_client = pynng.TLSConfig(mode=pynng.TLSConfig.MODE_CLIENT, ca_string=f0.read(), own_cert_string=f1.read(), own_key_string=f2.read()) # NNG_TLS_MODE_CLIENT with pynng.Mqtt_quic(address, tls_config=tls_client) as mqtt: print(f"Make a connect msg") connmsg = pynng.Mqttmsg() connmsg.set_packet_type(1) # 0x01 Connect connmsg.set_connect_proto_version(4) # MqttV311 connmsg.set_connect_client_id(f"{client_id}") connmsg.set_connect_keep_alive(60) connmsg.set_connect_clean_session(True) mqtt.send_msg(connmsg) print(f"Send connect packet msg") while 1: pass

I use code above but can not connect server.

wanghaEMQ commented 1 year ago

TLS in QUIC is not fully supported in NanoSDK now. We are working on it. It would be supported in a couple of weeks.

Dawn369 commented 1 year ago

thanks,I will see weeks later.

wanghaEMQ commented 1 year ago

Hi @Dawn369

The TLS configuration in mqtt_quic was supported.

And an example examples/mqtt_quic_tls.py was provided