• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

lets encrypt certificate format

Q&A Forum › Category: ESP32 › lets encrypt certificate format
0 Vote Up Vote Down
Huzaifa Sserugo asked 12 months ago

Hello Santos, I have failed to configure tsl on my esp32, what is the best format for adding a certificate, I have been trying different ways but each comes with a new sort of errror. The current format is ;
the certificate is in cert4.h file

const char* cert4 = “MDIxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MQswCQYDVQQDEwJSMzAeFw0yNDA1MjQwMjIxMzJaFw0yNDA4MjIwMjIxMzFaMBkxFzAVBgNVBAMTDnNzZXJ1emFpZmEuY29tMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEOEwmkGYTzQZOyGp7HzGHKA=”;
 

deleted all new lines and remained with on long string
 
and the error code looks like this
 
start_ssl_client(): Starting socket
[121637][V][ssl_client.cpp:146] start_ssl_client(): Seeding the random number generator
[121638][V][ssl_client.cpp:155] start_ssl_client(): Setting up the SSL/TLS structure…
[121641][V][ssl_client.cpp:178] start_ssl_client(): Loading CA cert
[121648][E][ssl_client.cpp:37] _handle_error(): [start_ssl_client():187]: (-8576) X509 – The CRT/CRL/CSR format is invalid
, e.g. different type expected
 
 
I believe the settings on the server side are okay as I can do pub/sub succesfully between two android phones
 
kindly guide me through
 

Question Tags: Digital ocean, lets encrypt, MQTT, tsl
1 Answers
0 Vote Up Vote Down
Huzaifa Sserugo answered 12 months ago

I succeeded, I got the fullchain.pem from which I got the server certificate an rootCA certificate. The format I used is 
 

const char* serverCertificate = “—–BEGIN CERTIFICATE—–\n”
“zCdgddgdCAxugAwIBAgISBPF1g+DNKh/0Mcp/+UU/jNwPMA0GCSqGSIb3DQEBCwUA\n”
“MDIxCzAnnnnaJBgNVRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MQswCQYDVQQD\n”
“EwJSMasssdzAeFw0yNDA1MjQwMjzJaFw0yNDA4MjIwMjIxMzFaMBkxFzAVBgNVBAMT\n”
“DnNzZsaXJ1emFpZmEuY29tMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcigAEOEwmkGYT\n”
“zCocXGEwWHsP7/93im9QpsdaPSryU62nECaWTIz8F4oTa+6rvqBnSiPZefRyNYO3kTG\n”
….
…

“63rUeSk5C2UToX0/GYGsA6ytry3Wr0gVmcOLfmet4rr+GtpwVzPpn93Drs4fyEF+\n”
“xMBeZI0l/Q3RHZgMgHUwe43Y+48usmxIM7FJC7hg+rWJ0ExVsnG7qmxDAX0+u8H\n”
“5ej8yQJ9kHcsad7HzGHKA=\n”
“—–END CERTIFICATE—–“;

 

const char* rootCACertificate1 = \
“—–BEGIN CERTIFICATE—–\n” \
“frtv6gAwIBAgIRAJErCErPDBinU/bWLi56WnX1owDQYJKoZIhvcNAuytQAw\n” \
“TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoT6GVybmV0IFNlY3VyaXR5IFJlc2Vh\n” \
“cmNoIEdyb3VwMRUwEwYDhsJGxJU1JHIFJvb3QgWDEwHhcNMjAwOTA0MDAwMDAw\n” \

 
 
 
…..
 
and in main I put
 

espClient.setCACert(rootCACertificate1);
  espClient.setCertificate(serverCertificate);

  mqtt_client.setServer(mqtt_server, port);

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.