#include "pkix_interface.h"
#include "hw_emul/hw_interface.h"
#include "oxmverifycommon.h"
+#include "casecurityinterface.h"
#define TAG "SAMPLE_MANUFACTURER_CERT"
}
}
-OCStackResult confirmCB(void * ctx)
+OCStackResult confirmCB_thread()
{
- OC_UNUSED(ctx);
for (;;)
{
int userConfirm;
}
if (1 == userConfirm)
{
+ SendUserConfirm(true);
break;
}
else if (0 == userConfirm)
{
- return OC_STACK_USER_DENIED_REQ;
+ SendUserConfirm(false);
+ break;
}
printf(" Entered Wrong Number. Please Enter Again\n");
}
return OC_STACK_OK;
}
-OCStackResult confirmNoCertCB(void * ctx)
+OCStackResult confirmCB(void * ctx)
{
OC_UNUSED(ctx);
- for (;;)
- {
- int userConfirm;
-
- printf(" > Peer has no cert!\n");
- printf(" > Press 1 for confirmation\n");
- printf(" > Press 0 otherwise\n");
+ pthread_t threadId;
+ pthread_create (&threadId, NULL, &confirmCB_thread, NULL);
+ return OC_STACK_OK;
+}
- for (int ret=0; 1!=ret; )
- {
- ret = scanf("%d", &userConfirm);
- for (; 0x20<=getchar(); ); // for removing overflow garbage
- // '0x20<=code' is character region
- }
- if (1 == userConfirm)
- {
- break;
- }
- else if (0 == userConfirm)
- {
- return OC_STACK_USER_DENIED_REQ;
- }
- printf(" Entered Wrong Number. Please Enter Again\n");
+void confirmNoCertCB(CACertificateVerificationStatus_t status)
+{
+ if (CA_CERTIFICATE_VERIFY_SUCCESS_MUTUAL == status)
+ {
+ printf(" > Peer certificate verification successful");
}
- return OC_STACK_OK;
+ else if (CA_CERTIFICATE_VERIFY_NO_CERT == status)
+ {
+ printf(" > Peer has not provided certificate\n");
+ }
+ else if (CA_CERTIFICATE_VERIFY_FAILED == status)
+ {
+ printf(" > Peer certificate verification failed\n");
+ }
+ return;
}
+void informOxmSelCB(OicSecOxm_t oxmSel)\r
+{\r
+ printf(" > OXM selected: 0x%x\n", oxmSel);\r
+}\r
+\r
FILE* server_fopen(const char *path, const char *mode)
{
(void)path;
// Initialize Persistent Storage for SVR database
OCPersistentStorage ps = {server_fopen, fread, fwrite, fclose, unlink, NULL, NULL};
- SetUserConfirmCB(NULL, confirmCB);
- CAsetNoCertConfirmCallback(confirmNoCertCB);
+ SetAsyncUserConfirmCB(NULL, confirmCB);
+ SetInformOxmSelCB(informOxmSelCB);
+ CAsetCertificateVerificationCallback(confirmNoCertCB);
OCRegisterPersistentStorageHandler(&ps);