OPCFoundation / UA-.NETStandard

OPC Unified Architecture .NET Standard
Other
1.97k stars 950 forks source link

Unable to reconnect a server which has changed its certificate #2713

Closed ccasteyde closed 2 months ago

ccasteyde commented 3 months ago

Type of issue

Current Behavior

If a client use the auto reconnect mechanism, it fails indefinitly to reconnect to the server if the server is shut down and reconfigured with an updated certificate, even if the endpoint use no security. This is because Session.Open checks several security points even if no security is used, and it checks that the Create service returns the same certificate as the one stored in the endpoint. This check is fine but the endpoint is not updated by reconnection code, so it has the previous certificate. There are similar errors if the server change its configuration, and the client should use another endpoint that the one it has used for the first connection for instance.

Expected Behavior

One should be able at least to update the server certificate without having to restart all OPC UA client processes.

Steps To Reproduce

Connect a client to a server. Shut down the server. Change the server certificate. Restart the server. If the client use reconnection mechanism, it won't reconnecte until it is restarted.

Environment

- OS:
- Environment:
- Runtime:
- Nuget Version:
- Component:
- Server:
- Client:

Anything else?

No response

romanett commented 2 months ago

@ccasteyde The session reconnect handler does already try to handle this case, can you try in a debugging session if this logic is triggered: https://github.com/OPCFoundation/UA-.NETStandard/blob/6dcee7ebf1f790d34c94883ff7572852086494f2/Libraries/Opc.Ua.Client/Session/SessionReconnectHandler.cs#L422-L427

https://github.com/OPCFoundation/UA-.NETStandard/blob/6dcee7ebf1f790d34c94883ff7572852086494f2/Libraries/Opc.Ua.Client/Session/SessionReconnectHandler.cs#L467-L474

ccasteyde commented 2 months ago

Hello

OK, I’m using an old stack version so I do not have this code present. That explains my problem. I’ll update to the latest code. Thanks