[IOT-3219][IOT-3220] Restore default handlers 35/27335/2
authorAleksey Volkov <a.volkov@samsung.com>
Mon, 29 Oct 2018 14:48:59 +0000 (16:48 +0200)
committerNathan Heldt-Sheller <nathan.heldt-sheller@intel.com>
Mon, 5 Nov 2018 19:19:06 +0000 (19:19 +0000)
Restore default TLS handlers immediatelly after PSK generation
in case of MFG OTM

Change-Id: Idfce0bf8e2b6741d0a64a8f0143e2eb955e7167e
Signed-off-by: Aleksey Volkov <a.volkov@samsung.com>
resource/csdk/security/src/credresource.c

index a58f437..b30ddc3 100644 (file)
@@ -66,6 +66,8 @@
 #endif
 
 #if defined(__WITH_DTLS__) || defined (__WITH_TLS__)
+#include "pkix_interface.h"
+
 #include <mbedtls/ssl_ciphersuites.h>
 #include <mbedtls/pk.h>
 #include <mbedtls/base64.h>
@@ -2212,6 +2214,20 @@ static OCEntityHandlerResult HandleNewCredential(OCEntityHandlerRequest *ehReque
 #endif // __WITH_DTLS__ or __WITH_TLS__
                     }
 
+                    if(OIC_MANUFACTURER_CERTIFICATE== doxm->oxmSel)
+                    {
+#if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
+                        if(CA_STATUS_OK != CAregisterPkixInfoHandler(GetPkixInfo)
+                            || CA_STATUS_OK != CAregisterIdentityHandler(GetIdentityHandler)
+                            || CA_STATUS_OK != CAregisterGetCredentialTypesHandler(InitCipherSuiteList))
+                        {
+                            OIC_LOG(ERROR, TAG, "Failed to revert TLS default handlers.");
+                            ret = OC_EH_ERROR;
+                            break;
+                        }
+#endif // __WITH_DTLS__ or __WITH_TLS__
+                    }
+
                     //Select cipher suite to use owner PSK
                     if(CA_STATUS_OK != CAEnableAnonECDHCipherSuite(false))
                     {