void Service_OpenSecureChannel(UA_Server *server, UA_Connection *connection, const UA_OpenSecureChannelRequest *request, UA_OpenSecureChannelResponse *response) { // todo: if(request->clientProtocolVersion != protocolVersion) if(request->requestType == UA_SECURITYTOKENREQUESTTYPE_ISSUE) { response->responseHeader.serviceResult = UA_SecureChannelManager_open(&server->secureChannelManager, connection, request, response); if(response->responseHeader.serviceResult == UA_STATUSCODE_GOOD) UA_LOG_DEBUG(server->logger, UA_LOGCATEGORY_SECURECHANNEL, "Opened SecureChannel %i on Connection %i", response->securityToken.channelId, connection->sockfd); else UA_LOG_DEBUG(server->logger, UA_LOGCATEGORY_SECURECHANNEL, "Opening SecureChannel on Connection %i failed", connection->sockfd); } else { response->responseHeader.serviceResult = UA_SecureChannelManager_renew(&server->secureChannelManager, connection, request, response); if(response->responseHeader.serviceResult == UA_STATUSCODE_GOOD) UA_LOG_DEBUG(server->logger, UA_LOGCATEGORY_SECURECHANNEL, "Renewed SecureChannel %i on Connection %i", response->securityToken.channelId, connection->sockfd); else UA_LOG_DEBUG(server->logger, UA_LOGCATEGORY_SECURECHANNEL, "Renewing SecureChannel on Connection %i failed", connection->sockfd); } }
void Service_OpenSecureChannel(UA_Server *server, UA_SecureChannel *channel, const UA_OpenSecureChannelRequest *request, UA_OpenSecureChannelResponse *response) { if(request->requestType == UA_SECURITYTOKENREQUESTTYPE_RENEW) { /* Renew the channel */ response->responseHeader.serviceResult = UA_SecureChannelManager_renew(&server->secureChannelManager, channel, request, response); /* Logging */ if(response->responseHeader.serviceResult == UA_STATUSCODE_GOOD) { UA_LOG_DEBUG_CHANNEL(server->config.logger, channel, "SecureChannel renewed"); } else { UA_LOG_DEBUG_CHANNEL(server->config.logger, channel, "Renewing SecureChannel failed"); } return; } /* Must be ISSUE or RENEW */ if(request->requestType != UA_SECURITYTOKENREQUESTTYPE_ISSUE) { response->responseHeader.serviceResult = UA_STATUSCODE_BADINTERNALERROR; return; } /* Open the channel */ response->responseHeader.serviceResult = UA_SecureChannelManager_open(&server->secureChannelManager, channel, request, response); /* Logging */ if(response->responseHeader.serviceResult == UA_STATUSCODE_GOOD) { UA_LOG_INFO_CHANNEL(server->config.logger, channel, "Opened SecureChannel"); } else { UA_LOG_INFO_CHANNEL(server->config.logger, channel, "Opening a SecureChannel failed"); } }