mbed Connector Interface simplification API on top of mbed-client
Fork of mbedConnectorInterfaceV3 by
NOTE:
This repo has been replaced with https://github.com/ARMmbed/mbedConnectorInterface. No further updates will occur with this repo. Please use the github repo instead. Thanks!
Diff: source/OptionsBuilder.cpp
- Revision:
- 49:c603a22495bb
- Parent:
- 38:bb6d2be4d54c
- Child:
- 50:4f04727cbf91
--- a/source/OptionsBuilder.cpp Mon Jun 20 20:09:44 2016 +0000 +++ b/source/OptionsBuilder.cpp Thu Jun 23 22:26:15 2016 +0000 @@ -50,6 +50,12 @@ this->m_reg_update_period = REG_UPDATE_PERIOD_MS; this->m_lifetime = REG_LIFETIME_SEC; this->m_connector_url = string(CONNECTOR_URL); + this->m_server_cert - NULL; + this->m_server_cert_length = 0; + this->m_client_cert = NULL; + this->m_client_cert_length = 0; + this->m_client_key = NULL; + this->m_client_key_length = 0; this->m_device_resources_object = NULL; this->m_firmware_resources_object = NULL; this->m_static_resources.clear(); @@ -66,6 +72,12 @@ this->m_reg_update_period = ob.m_reg_update_period; this->m_lifetime = ob.m_lifetime; this->m_connector_url = ob.m_connector_url; + this->m_server_cert - ob.m_server_cert; + this->m_server_cert_length = ob.m_server_cert_length; + this->m_client_cert = ob.m_client_cert; + this->m_client_cert_length = ob.m_client_cert_length; + this->m_client_key = ob.m_client_key; + this->m_client_key_length= ob.m_client_key_length; this->m_device_resources_object = ob.m_device_resources_object; this->m_firmware_resources_object = ob.m_firmware_resources_object; this->m_static_resources = ob.m_static_resources; @@ -291,41 +303,23 @@ } // set the server certificate -OptionsBuilder &OptionsBuilder::setServerCertificate(uint8_t cert[],int cert_size) { - memset(this->m_server_cert,0,MAX_SERVER_CERT_LENGTH); - int length = cert_size; - if (length > MAX_SERVER_CERT_LENGTH) { - length = MAX_SERVER_CERT_LENGTH; - DEBUG_OUT("WARNING: Truncated Server Certificate: orig: %d bytes (trunc: %d bytes)\r\n",cert_size,length); - } - memcpy(this->m_server_cert,cert,length); - this->m_server_cert_length = length; +OptionsBuilder &OptionsBuilder::setServerCertificate(uint8_t *cert,int cert_size) { + this->m_server_cert = cert; + this->m_server_cert_length = cert_size; return *this; } // set the client certificate -OptionsBuilder &OptionsBuilder::setClientCertificate(uint8_t cert[],int cert_size) { - memset(this->m_client_cert,0,MAX_CLIENT_CERT_LENGTH); - int length = cert_size; - if (length > MAX_CLIENT_CERT_LENGTH) { - length = MAX_CLIENT_CERT_LENGTH; - DEBUG_OUT("WARNING: Truncated Client Certificate: orig: %d bytes (trunc: %d bytes)\r\n",cert_size,length); - } - memcpy(this->m_client_cert,cert,length); - this->m_client_cert_length = length; +OptionsBuilder &OptionsBuilder::setClientCertificate(uint8_t *cert,int cert_size) { + this->m_client_cert = cert; + this->m_client_cert_length = cert_size; return *this; } // set the client key -OptionsBuilder &OptionsBuilder::setClientKey(uint8_t key[],int key_size) { - memset(this->m_client_key,0,MAX_CLIENT_KEY_LENGTH); - int length = key_size; - if (length > MAX_CLIENT_KEY_LENGTH) { - length = MAX_CLIENT_KEY_LENGTH; - DEBUG_OUT("WARNING: Truncated Client Key: orig: %d bytes (trunc: %d bytes)\r\n",key_size,length); - } - memcpy(this->m_client_key,key,length); - this->m_client_key_length = length; +OptionsBuilder &OptionsBuilder::setClientKey(uint8_t *key,int key_size) { + this->m_client_key = key; + this->m_client_key_length = key_size; return *this; }