Commit 0b17d266 authored by Oleksii Beketov's avatar Oleksii Beketov Committed by Nathan Heldt-Sheller

[IOT-3260] SSL close callback

Added callback to return peer's UUID
on SSL connection closure

Change-Id: Ib31250c639b9c2633e1459f0d555424ca429fb26
Signed-off-by: default avatarOleksii Beketov <ol.beketov@samsung.com>
parent 96e14db8
...@@ -83,6 +83,22 @@ void CAsetCredentialTypesCallback(CAgetCredentialTypesHandler credTypesCallback) ...@@ -83,6 +83,22 @@ void CAsetCredentialTypesCallback(CAgetCredentialTypesHandler credTypesCallback)
*/ */
void CAsetSslCredentialsCallback(CAgetPskCredentialsHandler credCallback); void CAsetSslCredentialsCallback(CAgetPskCredentialsHandler credCallback);
/**
* Callback to return peer's UUID on SSL session closure
*
* @param[out] uuid peer's UUID
* @param[out] uuidLen peer's UUID length
*
* @return CA_STATUS_OK or CA_STATUS_FAIL
*/
typedef CAResult_t (*CAcloseSslConnectionCallback)(const unsigned char *uuid, size_t uuidLen);
/**
* Register callback that returns peer's UUID on SSL session closure
* @param[in] cb callback to return peer's UUID on SSL session closure
*/
void CAsetCloseSslConnectionCallback(CAcloseSslConnectionCallback cb);
/** /**
* Close the TLS session * Close the TLS session
* *
......
...@@ -418,6 +418,12 @@ static CAgetPkixInfoHandler g_getPkixInfoCallback = NULL; ...@@ -418,6 +418,12 @@ static CAgetPkixInfoHandler g_getPkixInfoCallback = NULL;
* @brief callback to retrieve acceptable UUID list * @brief callback to retrieve acceptable UUID list
*/ */
static CAgetIdentityHandler g_getIdentityCallback = NULL; static CAgetIdentityHandler g_getIdentityCallback = NULL;
/**
* @var g_closeSslConnectionCallback
*
* @brief callback to retrieve UUID on SSL connection closure
*/
static CAcloseSslConnectionCallback g_closeSslConnectionCallback = NULL;
/** /**
* @var g_dtlsContextMutex * @var g_dtlsContextMutex
...@@ -504,6 +510,13 @@ void CAsetPeerCNVerifyCallback(PeerCNVerifyCallback cb) ...@@ -504,6 +510,13 @@ void CAsetPeerCNVerifyCallback(PeerCNVerifyCallback cb)
OIC_LOG_V(DEBUG, NET_SSL_TAG, "OUT %s", __func__); OIC_LOG_V(DEBUG, NET_SSL_TAG, "OUT %s", __func__);
} }
void CAsetCloseSslConnectionCallback(CAcloseSslConnectionCallback closeSslCallback)
{
OIC_LOG_V(DEBUG, NET_SSL_TAG, "In %s", __func__);
g_closeSslConnectionCallback = closeSslCallback;
OIC_LOG_V(DEBUG, NET_SSL_TAG, "Out %s", __func__);
}
/** /**
* Sets SSL result for callback. * Sets SSL result for callback.
* *
...@@ -1274,7 +1287,7 @@ CAResult_t CAcloseSslConnection(const CAEndpoint_t *endpoint) ...@@ -1274,7 +1287,7 @@ CAResult_t CAcloseSslConnection(const CAEndpoint_t *endpoint)
ret = mbedtls_ssl_close_notify(&tep->ssl); ret = mbedtls_ssl_close_notify(&tep->ssl);
} }
while (MBEDTLS_ERR_SSL_WANT_WRITE == ret); while (MBEDTLS_ERR_SSL_WANT_WRITE == ret);
g_closeSslConnectionCallback(tep->sep.identity.id, tep->sep.identity.id_length);
RemovePeerFromList(&tep->sep.endpoint); RemovePeerFromList(&tep->sep.endpoint);
oc_mutex_unlock(g_sslContextMutex); oc_mutex_unlock(g_sslContextMutex);
......
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
#define SetCASecureEndpointAttribute SetCASecureEndpointAttributeTest #define SetCASecureEndpointAttribute SetCASecureEndpointAttributeTest
#define GetCASecureEndpointAttributes GetCASecureEndpointAttributesTest #define GetCASecureEndpointAttributes GetCASecureEndpointAttributesTest
#define CAsetPeerCNVerifyCallback CAsetPeerCNVerifyCallbackTest #define CAsetPeerCNVerifyCallback CAsetPeerCNVerifyCallbackTest
#define CAsetCloseSslConnectionCallback CAsetCloseSslConnectionCallbackTest
#include "../src/adapter_util/ca_adapter_net_ssl.c" #include "../src/adapter_util/ca_adapter_net_ssl.c"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment