# Can't create ssl successfully, i need help

**URL:** <https://community.hivemq.com/t/cant-create-ssl-successfully-i-need-help/2319>\
**Category:** Uncategorized\
**Created:** [August 26, 2023, 5:41am UTC](https://community.hivemq.com/t/cant-create-ssl-successfully-i-need-help/2319 "2023-08-26T05:41:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![linh](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.hivemq.com/linh/32/776_2.png) [@linh](https://community.hivemq.com/u/linh)\
**Post date:** [August 26, 2023, 5:41am UTC](https://community.hivemq.com/t/cant-create-ssl-successfully-i-need-help/2319/1 "2023-08-26T05:41:25Z")

</div>

@Aaron Franz sorry to bother you , but i tried many ways and still cant generate an ssl certificate for 4038011a2fdc4d9b8c3123a10cc5f620.s2.eu.hivemq.cloud can you help me create a certificate for it thanks Friend

---

<div class="post-metadata">

**Author:** ![AaronTLFranz](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.hivemq.com/aarontlfranz/32/638_2.png) [@AaronTLFranz](https://community.hivemq.com/u/AaronTLFranz)\
**Post date:** [August 28, 2023, 12:26pm UTC](https://community.hivemq.com/t/cant-create-ssl-successfully-i-need-help/2319/2 "2023-08-28T12:26:52Z")

</div>

Hello @linh,

First off, welcome to the HiveMQ Community! Always happy to see new users joining in here in the community forum.

As for the SSL certificate, the server CA file can actually be obtained from right here in our community forum - [here](https://community.hivemq.com/t/frequently-asked-questions/514) is a quick link to the thread, and [here](https://letsencrypt.org/certs/isrgrootx1.pem) is a direct link to the server CA file.

This CA file can be used directly with some clients, or be used to create a client certificate if necessary following our how-to guides [here](https://docs.hivemq.com/hivemq/4.18/user-guide/howtos.html). Note that you will only need to follow the client certificate creation steps listed here, as we already have the server CA file and HiveMQ Cloud brokers are already configured to support TLS.

Best,  
Aaron from the HiveMQ Team

---

<div class="post-metadata">

**Author:** ![linh](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.hivemq.com/linh/32/776_2.png) [@linh](https://community.hivemq.com/u/linh)\
**Post date:** [September 9, 2023, 3:40pm UTC](https://community.hivemq.com/t/cant-create-ssl-successfully-i-need-help/2319/3 "2023-09-09T15:40:58Z")

</div>

I’m sorry to bother you again, but I wrote the simple code as below but still can’t connect to 4038011a2fdc4d9b8c3123a10cc5f620.s2.eu.hivemq.cloud, the wifi password or account to log in is fine. enter correctly

#include \<WiFi.h\>  
#include \<WiFiClientSecure.h\>  
#include \<PubSubClient.h\>

const char\* ssid = “redmi001”;  
const char\* password = “13062002”;  
std::string mess\_to\_client = “”;

const char\* mqttServer = “4038011a2fdc4d9b8c3123a10cc5f620.s2.eu.hivemq.cloud”;  
const int mqttPort = 1883;

const char\* mqttUsername = “…”;  
const char\* mqttPassword = “…”;  
const char\* mqttOutputTopic = “s-c”;  
const char\* rootCACertificate = “-----BEGIN CERTIFICATE-----\n”  
“MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw\n”  
“TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh\n”  
“cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4\n”  
“WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJu\n”  
“ZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBY\n”  
“MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54rVygc\n”  
“h77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+\n”  
“0TM8ukj13Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6U\n”  
“A5/TR5d8mUgjU+g4rk8Kb4Mu0UlXjIB0ttov0DiNewNwIRt18jA8+o+u3dpjq+sW\n”  
“T8KOEUt+zwvo/7V3LvSye0rgTBIlDHCNAymg4VMk7BPZ7hm/ELNKjD+Jo2FR3qyH\n”  
“B5T0Y3HsLuJvW5iB4YlcNHlsdu87kGJ55tukmi8mxdAQ4Q7e2RCOFvu396j3x+UC\n”  
“B5iPNgiV5+I3lg02dZ77DnKxHZu8A/lJBdiB3QW0KtZB6awBdpUKD9jf1b0SHzUv\n”  
“KBds0pjBqAlkd25HN7rOrFleaJ1/ctaJxQZBKT5ZPt0m9STJEadao0xAH0ahmbWn\n”  
“OlFuhjuefXKnEgV4We0+UXgVCwOPjdAvBbI+e0ocS3MFEvzG6uBQE3xDk3SzynTn\n”  
“jh8BCNAw1FtxNrQHusEwMFxIt4I7mKZ9YIqioymCzLq9gwQbooMDQaHWBfEbwrbw\n”  
“qHyGO0aoSCqI3Haadr8faqU9GY/rOPNk3sgrDQoo//fb4hVC1CLQJ13hef4Y53CI\n”  
“rU7m2Ys6xt0nUW7/vGT1M0NPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNV\n”  
“HRMBAf8EBTADAQH/MB0GA1UdDgQWBBR5tFnme7bl5AFzgAiIyBpY9umbbjANBgkq\n”  
“hkiG9w0BAQsFAAOCAgEAVR9YqbyyqFDQDLHYGmkgJykIrGF1XIpu+ILlaS/V9lZL\n”  
“ubhzEFnTIZd+50xx+7LSYK05qAvqFyFWhfFQDlnrzuBZ6brJFe+GnY+EgPbk6ZGQ\n”  
“3BebYhtF8GaV0nxvwuo77x/Py9auJ/GpsMiu/X1+mvoiBOv/2X/qkSsisRcOj/KK\n”  
“NFtY2PwByVS5uCbMiogziUwthDyC3+6WVwW6LLv3xLfHTjuCvjHIInNzktHCgKQ5\n”  
“ORAzI4JMPJ+GslWYHb4phowim57iaztXOoJwTdwJx4nLCgdNbOhdjsnvzqvHu7Ur\n”  
“TkXWStAmzOVyyghqpZXjFaH3pO3JLF+l+/+sKAIuvtd7u+Nxe5AW0wdeRlN8NwdC\n”  
“jNPElpzVmbUq4JUagEiuTDkHzsxHpFKVK7q4+63SM1N95R1NbdWhscdCb+ZAJzVc\n”  
“oyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq\n”  
“4RgqsahDYVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPA\n”  
“mRGunUHBcnWEvgJBQl9nJEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57d\n”  
“emyPxgcYxn/eR44/KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc=\n”  
“-----END CERTIFICATE-----”;

WiFiClientSecure espClient;  
PubSubClient mqttClient(espClient);

void setup() {  
Serial.begin(115200);  
WiFi.begin(ssid, password);  
while (WiFi.status() != WL\_CONNECTED) {  
Serial.println(“Connecting to WiFi…”);  
delay(1000);  
}

espClient.setCACert(rootCACertificate);  
mqttClient.setServer(mqttServer, mqttPort);

while (!mqttClient.connected()) {  
if (mqttClient.connect(String(random(0xffff), HEX).c\_str(), mqttUsername, mqttPassword)) {  
} else {  
Serial.println(mqttClient.state());  
delay(1000);  
}  
}  
}

void loop() {  
mess\_to\_client = “mess”;  
mqttClient.publish(mqttOutputTopic, mess\_to\_client.c\_str());  
Serial.println(“mess”);  
mqttClient.loop();  
delay(2000);  
}

and ter returns error -2

Connecting to WiFi…  
Connecting to WiFi…  
Connecting to WiFi…  
Connecting to WiFi…  
-2  
-2  
-2  
-2  
-2  
-2

---

<div class="post-metadata">

**Author:** ![Daria\_H](https://avatars.discourse-cdn.com/v4/letter/d/dfb087/32.png) [@Daria\_H](https://community.hivemq.com/u/Daria_H)\
**Post date:** [September 9, 2023, 4:11pm UTC](https://community.hivemq.com/t/cant-create-ssl-successfully-i-need-help/2319/4 "2023-09-09T16:11:29Z")

</div>

Hi @linh! Try the port 8883.
