File tree Expand file tree Collapse file tree 1 file changed +33
-1
lines changed
libraries/SocketWrapper/src Expand file tree Collapse file tree 1 file changed +33
-1
lines changed Original file line number Diff line number Diff line change 2121#define MBEDSSLCLIENT_H
2222
2323#include " MbedClient.h"
24+ #include < FATFileSystem.h>
25+ #include < MBRBlockDevice.h>
26+ #include < QSPIFBlockDevice.h>
2427
2528extern const char CA_CERTIFICATES[];
2629
@@ -44,9 +47,38 @@ class MbedSSLClient : public arduino::MbedClient {
4447 _disableSNI = statusSNI;
4548 }
4649
50+ void appendCustomCACert (const char * ca_cert) {
51+ _ca_cert_custom = ca_cert;
52+ }
53+
54+ protected:
55+ const char * _ca_cert_custom = NULL ;
56+
4757private:
4858 int setRootCA () {
49- return ((TLSSocket*)sock)->set_root_ca_cert_path (" /wlan/" );
59+ mbed::BlockDevice* root = mbed::BlockDevice::get_default_instance ();
60+ int err = root->init ();
61+ if ( err != QSPIF_BD_ERROR_OK) {
62+ return err;
63+ }
64+
65+ mbed::MBRBlockDevice wifi_data (root, 1 );
66+ mbed::FATFileSystem wifi (" wlan" );
67+
68+ err = wifi.mount (&wifi_data);
69+ if (err) {
70+ return err;
71+ }
72+
73+ err = ((TLSSocket*)sock)->set_root_ca_cert_path (" /wlan/" );
74+ if ( err != NSAPI_ERROR_OK) {
75+ return err;
76+ }
77+
78+ if (_ca_cert_custom != NULL ) {
79+ err = ((TLSSocket*)sock)->append_root_ca_cert (_ca_cert_custom);
80+ }
81+ return err;
5082 }
5183
5284 bool _disableSNI;
You can’t perform that action at this time.
0 commit comments