fix(opcuaclient): review r0 minors m1-m10
- m1: the form hint now says ProbeTimeoutSeconds can only shorten Test Connect's 10 s budget (passing the configured value as the button's budget is shared code - follow-up). - m2: a superseded init no longer overwrites _options (generation-checked under _probeLock) or the cert-validation handler (handed back and published with the session; detached when not installed; a previous one detached on replace). - m3: an ack none of whose condition ids resolves throws BadNodeIdUnknown + Warning. - m4: an ack with no reply (transport failure / non-caller timeout) degrades. - m5: no session before the gate is the same ServiceResultException(BadNotConnected). - m6: the caller-cancelled-write deviation is documented. - m7: a reply during a published outage advances the stamp but does not write Healthy; the keep-alive recovery ends the outage. - m8: test for a non-caller OperationCanceledException write -> Degraded. - m9: the browse session owns and disposes the user certificate it loaded (OpcUaUserIdentityFactory.LoadCertificate; a key-less cert is disposed before the throw); AdminUI-host certificate path documented. - m10: a subscribe overtaken by a shutdown / re-init removes its half-built subscription instead of registering it (data and alarm). - Sync Dispose drains each gate for 500 ms (was 2 s). Refs #743 Claude-Session: https://claude.ai/code/session_01Ub9hGmYLQvn9XETzw7CMsT
This commit is contained in:
+13
-2
@@ -37,7 +37,15 @@ public static class OpcUaUserIdentityFactory
|
||||
/// </summary>
|
||||
/// <param name="options">Driver options containing certificate configuration.</param>
|
||||
/// <returns>The certificate-backed <see cref="UserIdentity"/>.</returns>
|
||||
public static UserIdentity FromCertificate(OpcUaClientDriverOptions options)
|
||||
public static UserIdentity FromCertificate(OpcUaClientDriverOptions options) => new(LoadCertificate(options));
|
||||
|
||||
/// <summary>
|
||||
/// Loads (and validates) the user-authentication certificate <see cref="FromCertificate"/> wraps. The caller owns
|
||||
/// the returned certificate — dispose it when the session that presented it is gone.
|
||||
/// </summary>
|
||||
/// <param name="options">Driver options containing certificate configuration.</param>
|
||||
/// <returns>The certificate, with its private key.</returns>
|
||||
public static System.Security.Cryptography.X509Certificates.X509Certificate2 LoadCertificate(OpcUaClientDriverOptions options)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(options.UserCertificatePath))
|
||||
throw new InvalidOperationException(
|
||||
@@ -53,11 +61,14 @@ public static class OpcUaUserIdentityFactory
|
||||
.LoadPkcs12FromFile(options.UserCertificatePath, options.UserCertificatePassword);
|
||||
|
||||
if (!cert.HasPrivateKey)
|
||||
{
|
||||
cert.Dispose();
|
||||
throw new InvalidOperationException(
|
||||
$"User certificate at '{options.UserCertificatePath}' has no private key — " +
|
||||
"the private key is required to sign the OPC UA user-token challenge at session activation.");
|
||||
}
|
||||
|
||||
return new UserIdentity(cert);
|
||||
return cert;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user