knolleary / pubsubclient

A client library for the Arduino Ethernet Shield that provides support for MQTT.
http://pubsubclient.knolleary.net/
MIT License
3.78k stars 1.46k forks source link

Unable to connect to cloudmqtt site using pubsubclient via ssl port #545

Open dronebat opened 5 years ago

dronebat commented 5 years ago

I am unable to connect to cloudmqtt site using pubsubclient via ssl port. Works only with unsecured port, while both SSL port and Websockets Port (TLS only) port are not working.

Platform: ESP8266 Arduino1.8.5 with core 2.5.0-beta1 Server m10.cloudmqtt.com Port 10635 SSL Port 20635 Websockets Port (TLS only) 30635

Declaration:

const int mqtt_port_tls = 20635; //SSL Port  20635
//const int mqtt_port_wstls = 30635;  //Websockets Port (TLS only)  30635
//formated fingerprint of cloudmqtt site via condo rootca comodorsaaddtrustca.pem
//using https://m10.cloudmqtt.com:* 
const char* fingerprint = "39 DF B6 55 54 1D A4 53 12 70 65 DC 43 11 53 DA 3B A3 6E A8";

WiFiClientSecure wsecclient;  //Declares a WifiSecureClient Object using ESP8266WiFi
//PubSubClient client(wsecclient, mqtt_server,  mqtt_port_wstls);  //instantiates client object
PubSubClient client(wsecclient, mqtt_server,  mqtt_port_tls);  //instantiates client object

```This segment works >>>>>>>>
  if (!wsecclient.connect(mqtt_server, mqtt_port_tls)) {
    Serial.println("connection failed TLS ws");
    return;
  }

  if (wsecclient.verify(fingerprint, mqtt_server)) {
    Serial.println("certificate matches TLS ");
  } else {
    Serial.println("certificate doesn't match TLS");
  }

No match for this call >>>

if (client.connect(MQTT::Connect("mqtt_client_name") .set_auth(mqtt_user, mqtt_pass))) {


Can some one clarify whether this cloudmqtt.com site is accessible via PubSubClient  library, can point to sample code?
Thanks in advance...
knolleary commented 5 years ago

HI, the formatting of your post is a little broken so its hard to tell what is output versus your questions.

The line of code if (client.connect(MQTT::Connect("mqtt_client_name") is not using PubSubClient - but comes from one of the forks (I forget which) that has completely changed the API.

dronebat commented 5 years ago

My mistake , please point me example code to connect to SSL port using pubsubclient.