namespace ZB.MOM.WW.OtOpcUa.Client.Shared.Models; /// /// Settings for establishing an OPC UA client connection. /// public sealed class ConnectionSettings { /// /// The primary OPC UA endpoint URL. /// public string EndpointUrl { get; set; } = string.Empty; /// /// Optional failover endpoint URLs for redundancy. /// public string[]? FailoverUrls { get; set; } /// /// Optional username for authentication. /// public string? Username { get; set; } /// /// Optional password for authentication. /// public string? Password { get; set; } /// /// Transport security mode. Defaults to . /// public SecurityMode SecurityMode { get; set; } = SecurityMode.None; /// /// Session timeout in seconds. Defaults to 60. /// public int SessionTimeoutSeconds { get; set; } = 60; /// /// Whether to automatically accept untrusted server certificates. Defaults to true. /// public bool AutoAcceptCertificates { get; set; } = true; /// /// Gitea #816 — require the server certificate to list the host of the URL being connected (the operator's /// host: discovery keeps it in place of the server-advertised one) among its subject-alternative names; /// a mismatch fails the connect with BadCertificateHostNameInvalid. Defaults to false, the /// behaviour before #816 (the SDK overload used never checked). Secured connections only. Leave it off behind /// NAT / a port publish / when connecting by an IP the certificate does not name. /// public bool ValidateServerHostName { get; set; } /// /// Path to the certificate store. Defaults to ; the /// consuming application configuration factory resolves the canonical path via /// lazily on first connect, so /// constructing settings — including the throwaway copies built per failover /// attempt — does not touch disk or run the legacy-folder migration probe. /// public string CertificateStorePath { get; set; } = string.Empty; /// /// Validates the settings and throws if any required values are missing or invalid. /// /// Thrown when settings are invalid. public void Validate() { if (string.IsNullOrWhiteSpace(EndpointUrl)) throw new ArgumentException("EndpointUrl must not be null or empty.", nameof(EndpointUrl)); if (SessionTimeoutSeconds <= 0) throw new ArgumentException("SessionTimeoutSeconds must be greater than zero.", nameof(SessionTimeoutSeconds)); if (SessionTimeoutSeconds > 3600) throw new ArgumentException("SessionTimeoutSeconds must not exceed 3600.", nameof(SessionTimeoutSeconds)); } }