copercini / esp8266-aws_iot

Some examples using x.509 certificates and TLSv1.2 under Arduino IDE
117 stars 50 forks source link

BearSSL::WiFiClientSecure' has no member named 'loadCertificate' #23

Open vuanhachoi opened 3 years ago

vuanhachoi commented 3 years ago

When I try uploading the code into my WeMos D1 Mini board. It gives me the error below:

C:\Users\JakeNguyen\Desktop\ESP8266\mqtt_x509_DER\mqtt_x509_DER.ino: In function 'void setup()':
mqtt_x509_DER:117:17: error: 'class BearSSL::WiFiClientSecure' has no member named 'loadCertificate'
  117 |   if (espClient.loadCertificate(cert))
      |                 ^~~~~~~~~~~~~~~
mqtt_x509_DER:132:17: error: 'class BearSSL::WiFiClientSecure' has no member named 'loadPrivateKey'
  132 |   if (espClient.loadPrivateKey(private_key))
      |                 ^~~~~~~~~~~~~~
mqtt_x509_DER:149:18: error: 'class BearSSL::WiFiClientSecure' has no member named 'loadCACert'
  149 |     if(espClient.loadCACert(ca))
      |                  ^~~~~~~~~~
exit status 1
**'class BearSSL::WiFiClientSecure' has no member named 'loadCertificate'**

Im not sure how to fix this problem. If anyone has an idea how to fix it, please help me!

copercini commented 3 years ago

This code was initially designed for axTLS, so it has different APIs of BearSSL, but you can replace it using: setTrustAnchors and setRSACert

Like in this example: https://github.com/esp8266/Arduino/blob/da6ec83b5fdbd5b02f04cf143dcf8e158a8cfd36/libraries/ESP8266WiFi/examples/BearSSL_ServerClientCert/BearSSL_ServerClientCert.ino

vuanhachoi commented 3 years ago

Thank you for your response! Would it be possible you can tell me where I can replace it in the code please? From the exam you gave it, can I just copy set TrustAnchors and serRSACert into the original code or I can copy the whole void setup() function?