Skip to content

Commit

Permalink
fix(client): Fix endpoint selection when no UserTokenPolicy is requir…
Browse files Browse the repository at this point in the history
…ed (SecureChannel only)
  • Loading branch information
jpfr committed Oct 3, 2024
1 parent 0ccb615 commit c133670
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/client/ua_client_connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -928,9 +928,12 @@ responseGetEndpoints(UA_Client *client, void *userdata,
continue;
}

/* We have found a matching endpoint.
* But maybe not a amtching user token policy. */
bestEndpointIndex = i;
/* We have found a matching endpoint. Do we need a matching user token
* policy? */
if(client->config.noSession) {
bestEndpointIndex = i;
continue;
}

/* Compare the available UserTokenPolicies */
for(size_t j = 0; j < endpoint->userIdentityTokensSize; ++j) {
Expand Down Expand Up @@ -1006,6 +1009,7 @@ responseGetEndpoints(UA_Client *client, void *userdata,

/* Update tracking */
bestEndpointLevel = endpoint->securityLevel;
bestEndpointIndex = i;
bestTokenIndex = j;

/* Stop search for the UserTokenPolicy. But we go on searching for
Expand All @@ -1017,7 +1021,7 @@ responseGetEndpoints(UA_Client *client, void *userdata,
if(bestEndpointIndex == notFound) {
UA_LOG_ERROR(client->config.logging, UA_LOGCATEGORY_CLIENT,
"No suitable endpoint found");
client->connectStatus = UA_STATUSCODE_BADINTERNALERROR;
client->connectStatus = UA_STATUSCODE_BADIDENTITYTOKENINVALID;
closeSecureChannel(client);
UA_UNLOCK(&client->clientMutex);
return;
Expand Down

0 comments on commit c133670

Please sign in to comment.