Przeglądaj źródła

branch for connection securechannel development

FlorianPalm 11 lat temu
rodzic
commit
5eb7a29942

+ 4 - 2
examples/src/opcuaServerACPLT.c

@@ -55,7 +55,9 @@ void server_run() {
 	localBuffers.recvBufferSize = BUFFER_SIZE;
 
 	/*init secure Channel manager, which handles more than one channel */
-	SL_ChannelManager_init(2, 873);
+	UA_String endpointUrl;
+	UA_String_copycstring("open62541.org",&endpointUrl);
+	SL_ChannelManager_init(2,3600000, 873, 23, &endpointUrl);
 	UA_TL_Connection_new(&connection, localBuffers, (TL_Writer)NL_TCP_writer);
 
 
@@ -120,7 +122,7 @@ void server_run() {
 				perror("ERROR reading from socket1");
 				exit(1);
 			}
-			UA_TL_Connection_getState(connection,&connectionState);
+			UA_TL_Connection_getState(connection, &connectionState);
 		} while(connectionState != CONNECTIONSTATE_CLOSE);
 		shutdown(newsockfd,2);
 		close(newsockfd);

+ 1 - 1
src/ua_services.h

@@ -186,7 +186,7 @@ a component of an Object.
  * triggered item links to be deleted, but has no effect on the MonitoredItems
  * referenced by the triggered items.
  */
-UA_Int32 Service_CreateMonitoredItems(SL_Channel *channel, const UA_CreateMonitoredItemsRequest *request, UA_CreateMonitoredItemsResponse *response);
+UA_Int32 Service_CreateMonitoredItems(const UA_CreateMonitoredItemsRequest *request, UA_CreateMonitoredItemsResponse *response);
 // Service_ModifyMonitoredItems
 // Service_SetMonitoringMode
 // Service_SetTriggering

+ 31 - 5
src/ua_transport_binary.c

@@ -120,14 +120,40 @@ static UA_Int32 TL_handleOpen(UA_TL_Connection1 connection, const UA_ByteString*
 	UA_Int32 state;
 	UA_TL_Connection_getState(connection,&state);
 	SL_secureChannel channel = UA_NULL;
+
+	UA_ByteString receiverCertificateThumbprint;
+	UA_ByteString securityPolicyUri;
+	UA_ByteString senderCertificate;
+
 	if (state == CONNECTIONSTATE_ESTABLISHED) {
-	//	return SL_Channel_new(connection, msg, pos);
-		//UA_TL_Connection_getId(connection,connectionId);
 
-		if(SL_Channel_newByRequest(connection, msg, pos, &channel) == UA_SUCCESS)
-		{
 
-			SL_Channel_registerTokenProvider(channel, SL_ChannelManager_generateToken);
+		UA_alloc((void**)&receiverCertificateThumbprint.data, -1);
+		UA_alloc((void**)&securityPolicyUri.data, 47);
+		UA_alloc((void**)&senderCertificate.data, 0);
+
+		receiverCertificateThumbprint.data = UA_NULL;
+		receiverCertificateThumbprint.length = 0;
+
+		UA_String_copycstring("http://opcfoundation.org/UA/SecurityPolicy#None",(UA_String*)&securityPolicyUri);
+		securityPolicyUri.length = 47;
+
+		senderCertificate.data = UA_NULL;
+		senderCertificate.length = 0;
+
+		SL_Channel_new(&channel,
+				SL_ChannelManager_generateChannelId,
+				SL_ChannelManager_generateToken,
+				&receiverCertificateThumbprint,
+				&securityPolicyUri,
+				&senderCertificate,
+				UA_SECURITYMODE_INVALID);
+
+
+	//return SL_Channel_new(connection, msg, pos);
+	//UA_TL_Connection_getId(connection,connectionId);
+		if(SL_Channel_initByRequest(channel,connection, msg, pos) == UA_SUCCESS)
+		{
 			SL_ProcessOpenChannel(channel, msg, pos);
 			SL_ChannelManager_addChannel(channel);
 		}else

+ 2 - 1
src/ua_transport_binary_secure.c

@@ -83,9 +83,10 @@ static UA_Int32 SL_Send(SL_secureChannel channel,
 	if (isAsym)
 	{
 
-		SL_Channel_getLocalAsymAlgSettings(channel, asymAlgSettings);
+		SL_Channel_getLocalAsymAlgSettings(channel, &asymAlgSettings);
 		UA_AsymmetricAlgorithmSecurityHeader_encodeBinary(asymAlgSettings, &pos,
 				header);
+		UA_free(asymAlgSettings);
 	}
 	else
 	{

+ 3 - 3
src/ua_transport_binary_secure.h

@@ -26,7 +26,7 @@ typedef struct {
 	UA_DateTime createdAt;
 	UA_Int32 revisedLifetime;
 } SL_ChannelSecurityToken;
-
+/*
 typedef struct SL_Channel_T {
 	UA_String secureChannelId;
 	UA_TL_Connection1 tlConnection;
@@ -39,9 +39,9 @@ typedef struct SL_Channel_T {
 	UA_ByteString localNonce;
 	UA_UInt32 connectionState;
 	SL_ChannelSecurityToken securityToken;
-} SL_Channel;
-
+} SL_secureChannel;
 
+*/
 UA_Int32 SL_Process(const UA_ByteString* msg, UA_Int32* pos);
 
 /**