From ba4a9efcb94fae800164e35bfa2d7438392dffcb Mon Sep 17 00:00:00 2001 From: Jongmin Choi Date: Fri, 13 Jan 2017 15:41:34 +0900 Subject: [PATCH] Fix ownership transfer issues Fix issues related to ownership transfer - Port change after failed ownership transfer Patch #1: initial upload Patch #2: build error fix Change-Id: Ia6df0e7b862f73fab166ccb2c8ceee6c348b8189 Signed-off-by: Jongmin Choi Reviewed-on: https://gerrit.iotivity.org/gerrit/16371 Tested-by: jenkins-iotivity Reviewed-by: Joonghwan Lee Reviewed-by: Randeep Singh (cherry picked from commit 75bd7cd65fc5bdd362120ca2ac10d5d09a7755c5) Reviewed-on: https://gerrit.iotivity.org/gerrit/16417 Tested-by: jenkins-iotivity --- resource/csdk/connectivity/src/adapter_util/ca_adapter_net_ssl.c | 8 ++++---- .../csdk/security/provisioning/src/ownershiptransfermanager.c | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/resource/csdk/connectivity/src/adapter_util/ca_adapter_net_ssl.c b/resource/csdk/connectivity/src/adapter_util/ca_adapter_net_ssl.c index 37a9d15..bc0a256 100644 --- a/resource/csdk/connectivity/src/adapter_util/ca_adapter_net_ssl.c +++ b/resource/csdk/connectivity/src/adapter_util/ca_adapter_net_ssl.c @@ -235,21 +235,22 @@ if (0 != (ret) && MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY != (int) (ret) && MBEDTLS_SSL_ALERT_MSG_NO_APPLICATION_PROTOCOL != (int) (ret)) \ { \ OIC_LOG_V(ERROR, NET_SSL_TAG, "%s: -0x%x", (str), -(ret)); \ - if ((int) MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE != (int) (ret)) \ + if ((int) MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE != (int) (ret) && \ + (int) MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO != (int) (ret)) \ { \ mbedtls_ssl_send_alert_message(&(peer)->ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, (msg)); \ } \ - SSL_RES((peer), CA_DTLS_AUTHENTICATION_FAILURE); \ RemovePeerFromList(&(peer)->sep.endpoint); \ if (mutex) \ { \ oc_mutex_unlock(g_sslContextMutex); \ } \ + SSL_RES((peer), CA_DTLS_AUTHENTICATION_FAILURE); \ OIC_LOG_V(DEBUG, NET_SSL_TAG, "Out %s", __func__); \ if (-1 != error) \ { \ return (error); \ - } \ + } \ } /**@def CONF_SSL(clientConf, serverConf, fn, ...) * @@ -1841,7 +1842,6 @@ CAResult_t CAdecryptSsl(const CASecureEndpoint_t *sep, uint8_t *data, uint32_t d if (MBEDTLS_SSL_HANDSHAKE_OVER == peer->ssl.state) { - SSL_RES(peer, CA_STATUS_OK); if (MBEDTLS_SSL_IS_CLIENT == peer->ssl.conf->endpoint) { SendCacheMessages(peer); diff --git a/resource/csdk/security/provisioning/src/ownershiptransfermanager.c b/resource/csdk/security/provisioning/src/ownershiptransfermanager.c index 9fa52d9..24618ef 100644 --- a/resource/csdk/security/provisioning/src/ownershiptransfermanager.c +++ b/resource/csdk/security/provisioning/src/ownershiptransfermanager.c @@ -463,9 +463,9 @@ static void SetResult(OTMContext_t* otmCtx, const OCStackResult res) { OIC_LOG(WARNING, TAG, "Internal error in PDMDeleteDevice"); } - CAEndpoint_t* endpoint = (CAEndpoint_t *)&otmCtx->selectedDeviceInfo->endpoint; - endpoint->port = otmCtx->selectedDeviceInfo->securePort; - if (CA_STATUS_OK != CAcloseSslConnection(endpoint)) + CAEndpoint_t endpoint; + memcpy(&endpoint, &(otmCtx->selectedDeviceInfo->endpoint), sizeof(CAEndpoint_t)); + if (CA_STATUS_OK != CAcloseSslConnection(&endpoint)) { OIC_LOG(WARNING, TAG, "Failed to close Secure session"); } -- 2.7.4