Skip to content

Commit

Permalink
MbedSSLSE050Client: fix build for Nicla Vision
Browse files Browse the repository at this point in the history
  • Loading branch information
pennam committed Nov 8, 2024
1 parent 9031045 commit bf25224
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 26 deletions.
4 changes: 2 additions & 2 deletions libraries/SE05X/src/WiFiSSLSE050Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ arduino::MbedSSLSE050Client::MbedSSLSE050Client() {
void arduino::MbedSSLSE050Client::setEccSlot(int KeySlot, const byte cert[], int certLen) {

_keySlot = KeySlot;
_client_cert_len = certLen;
_client_cert = cert;
_certLen = certLen;
_cert = cert;
}

void WiFiSSLSE050Client::setEccSlot(int KeySlot, const byte cert[], int certLen) {
Expand Down
35 changes: 13 additions & 22 deletions libraries/SE05X/src/WiFiSSLSE050Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,37 +37,28 @@ class MbedSSLSE050Client : public arduino::MbedSSLClient {
void setEccSlot(int KeySlot, const byte cert[], int certLen);

private:
const byte* _client_cert;
const char* _ca_cert;
int _client_cert_len;
const byte* _cert;
int _certLen;
int _keySlot;
sss_object_t _keyObject;

int setRootCAClientCertKey() {
if( NSAPI_ERROR_OK != ((TLSSocket*)sock)->set_root_ca_cert_path("/wlan/")) {
return 0;
int err = setRootCA();
if (err != NSAPI_ERROR_OK) {
return err;
}

if(_hostname && !_disableSNI) {
((TLSSocket*)sock)->set_hostname(_hostname);
if(SE05X.getObjectHandle(_keySlot, &_keyObject) != NSAPI_ERROR_OK) {
return NSAPI_ERROR_DEVICE_ERROR;
}

if( NSAPI_ERROR_OK != ((TLSSocket*)sock)->append_root_ca_cert(_ca_cert_custom)) {
return 0;
if(((TLSSocket*)sock)->set_client_cert_key((void*)_cert,
(size_t)_certLen,
&_keyObject,
SE05X.getDeviceCtx()) != NSAPI_ERROR_OK) {
return NSAPI_ERROR_DEVICE_ERROR;
}

if(!SE05X.getObjectHandle(_keySlot, &_keyObject)) {
return 0;
}

if( NSAPI_ERROR_OK != ((TLSSocket*)sock)->set_client_cert_key((void*)_client_cert,
(size_t)_client_cert_len,
&_keyObject,
SE05X.getDeviceCtx())) {
return 0;
}

return 1;
return NSAPI_ERROR_OK;
}
};

Expand Down
4 changes: 2 additions & 2 deletions libraries/SocketWrapper/src/MbedSSLClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ class MbedSSLClient : public arduino::MbedClient {
_privateKey = privateKey;
}

protected:
private:
const char* _rootCA;
const char* _hostname;
const char* _clientCert;
const char* _privateKey;
bool _disableSNI;
bool _appendCA;

private:
protected:
int setRootCA() {
int err = 0;

Expand Down

0 comments on commit bf25224

Please sign in to comment.