In the tls connection, the subject name in the certificate is set to uuid.
So need this api to set the identity with doxm or device uuid.
Give the endpoint and uuid, it finds the peer and sets identity to uuid.
https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/pull/522/commits/
cb5bfdca63fd5919005e69988363f0d951aa75d9
(cherry picked from
cb5bfdca63fd5919005e69988363f0d951aa75d9)
Change-Id: I61b701e2fb95b2af61894431ece9c164e68f9c9e
Signed-off-by: Jaehong Jo <jaehong.jo@samsung.com>
Signed-off-by: Sudipto Bal <sudipto.bal@samsung.com>
*/
const CASecureEndpoint_t *CAGetSecureEndpointData(const CAEndpoint_t *peer);
#endif //MULTIPLE_OWNER
+
+/**
+ * API to set a secure endpoint identity with uuid
+ *
+ * @param[in] peer peer information includs IP address and port
+ * @param[in] uuid UUID of target device
+ *
+ * @return ::CA_STATUS_OK or appropriate error code
+ */
+CAResult_t CASetSecureEndpointUuid(const CAEndpoint_t *peer, const char *uuid);
#endif
/**
const CASecureEndpoint_t *GetCASecureEndpointData(const CAEndpoint_t* peer);
#endif
+/**
+ * Sets CA secure endpoint identity with uuid.
+ *
+ * @param[in] peer remote address
+ * @param[in] uuid UUID data to set
+ *
+ * @retval ::CA_STATUS_OK for success, otherwise some error value
+ */
+CAResult_t SetCASecureEndpointUuid(const CAEndpoint_t *peer, const char *uuid);
+
bool CAIsExistSslPeer(const CAEndpoint_t *peer);
#ifdef __cplusplus
}
#endif
+CAResult_t SetCASecureEndpointUuid(const CAEndpoint_t *peer, const char *uuid)
+{
+ OIC_LOG_V(DEBUG, NET_SSL_TAG, "In %s", __func__);
+ VERIFY_NON_NULL(peer, NET_SSL_TAG, "peer");
+ VERIFY_NON_NULL(peer, NET_SSL_TAG, "uuid");
+
+ oc_mutex_lock(g_sslContextMutex);
+ SslEndPoint_t *sslPeer = GetSslPeer(peer);
+ if (NULL == sslPeer)
+ {
+ OIC_LOG(ERROR, NET_SSL_TAG, "Peer not found");
+ oc_mutex_unlock(g_sslContextMutex);
+ return CA_STATUS_FAILED;
+ }
+
+ OCRandomUuidResult ret = OCConvertStringToUuid(uuid, sslPeer->sep.identity.id);
+ oc_mutex_unlock(g_sslContextMutex);
+
+ if (RAND_UUID_OK != ret)
+ {
+ OIC_LOG(ERROR, NET_SSL_TAG, "Failed to convert uuid");
+ return CA_STATUS_FAILED;
+ }
+
+ OIC_LOG_V(DEBUG, NET_SSL_TAG, "Out %s", __func__);
+
+ return CA_STATUS_OK;
+}
+
/**
* Deletes cached message.
*
}
#endif //MULTIPLE_OWNER
+CAResult_t CASetSecureEndpointUuid(const CAEndpoint_t *peer, const char *uuid)
+{
+ OIC_LOG(DEBUG, TAG, "IN CASetSecureEndpointUuid");
+
+ if (!g_isInitialized)
+ {
+ OIC_LOG(DEBUG, TAG, "CA is not initialized");
+ return CA_STATUS_NOT_INITIALIZED;
+ }
+
+ OIC_LOG(DEBUG, TAG, "OUT CASetSecureEndpointUuid");
+ return SetCASecureEndpointUuid(peer, uuid);
+}
+
CAResult_t CAregisterSslHandshakeCallback(CAErrorCallback tlsHandshakeCallback)
{
OIC_LOG(DEBUG, TAG, "CAregisterSslHandshakeCallback");
#endif
}
+TEST_F(CATests, SetSecureEndpointUuidTestWithNullPeer)
+{
+#ifdef __WITH_DTLS__
+ EXPECT_EQ(CA_STATUS_INVALID_PARAM, CASetSecureEndpointUuid(NULL, NULL));
+#endif
+}
+
// CARegisterNetworkMonitorHandler TC
TEST_F(CATests, RegisterNetworkMonitorHandler)
{