/* ======================================================================== * Copyright (c) 2005-2025 The OPC Foundation, Inc. All rights reserved. * * OPC Foundation MIT License 1.00 * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without * restriction, including without limitation the rights to use, * copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following * conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. * * The complete license agreement can be found here: * http://opcfoundation.org/License/MIT/1.00/ * ======================================================================*/ using System; using System.Collections.Generic; using Opc.Ua.Configuration; namespace Opc.Ua.Server.Hosting { /// /// Options for an OPC UA server hosted by the .NET Generic Host via /// . /// /// /// Only the most common knobs are exposed directly. Use /// for full control of the underlying /// chain (security policies, /// transport quotas, custom security stores, etc.). /// public sealed class OpcUaServerOptions { /// /// Application name. Used as the default for the certificate subject /// common-name and the PKI root path when those are not set explicitly. /// public string ApplicationName { get; set; } = "OpcUaServer"; /// /// Application URI (e.g. urn:localhost:Org:Product). /// public string ApplicationUri { get; set; } = string.Empty; /// /// Product URI (e.g. uri:org:product). /// public string ProductUri { get; set; } = string.Empty; /// /// Optional explicit certificate subject. When not set, defaults to /// CN={ApplicationName}, O=OPC Foundation, DC=localhost. /// public string SubjectName { get; set; } = string.Empty; /// /// Listen URLs. Mutated in place by options.EndpointUrls.Add(...). /// public IList EndpointUrls { get; } = []; /// /// Filesystem root used for the certificate stores. When empty, defaults /// to %TEMP%/OPC Foundation/{ApplicationName}/pki. /// public string PkiRoot { get; set; } = string.Empty; /// /// Whether unknown peer certificates are auto-accepted. Convenient for /// quickstart samples; do not enable in production. /// public bool AutoAcceptUntrustedCertificates { get; set; } /// /// Toggle the OPC UA server diagnostics node manager. /// public bool DiagnosticsEnabled { get; set; } = true; /// /// Maximum byte-string length advertised on the transport. Defaults to /// 4 MiB. /// public uint MaxByteStringLength { get; set; } = 4 * 1024 * 1024; /// /// Maximum array length advertised on the transport. Defaults to 1 Mi /// elements. /// public uint MaxArrayLength { get; set; } = 1024 * 1024; /// /// When true (default), AddSignAndEncryptPolicies() is applied to /// the configuration builder. /// public bool IncludeSignAndEncryptPolicies { get; set; } = true; /// /// When true, AddUnsecurePolicyNone() is applied to the /// configuration builder. Off by default. /// public bool IncludeUnsecurePolicyNone { get; set; } /// /// When true, ECC sign-and-encrypt security policies are added /// to the configuration builder via /// AddEccSignAndEncryptPolicies(). Off by default. /// public bool IncludeEccPolicies { get; set; } /// /// User-token policies to advertise on every endpoint. Each entry /// is appended via /// IApplicationConfigurationBuilderServerSelected.AddUserTokenPolicy. /// When this list is empty the hosted service falls back to /// . /// public IList UserTokenPolicies { get; } = []; /// /// Server-side identity authenticators and trusted JWT issuers. /// public OpcUaServerIdentityOptions Identity { get; set; } = new(); /// /// Maximum message size advertised on the transport, in bytes. /// When null, the stack default is kept. When set, the value /// is forwarded to /// IApplicationConfigurationBuilderTransportQuotas.SetMaxMessageSize. /// public int? MaxMessageSize { get; set; } /// /// Operation timeout advertised on the transport, in milliseconds. /// When null, the stack default is kept. When set, the value /// is forwarded to /// IApplicationConfigurationBuilderTransportQuotas.SetOperationTimeout. /// public int? OperationTimeoutMs { get; set; } /// /// Reject SHA-1-signed certificates during certificate validation /// (server-wide hardening). Defaults to true; flip to /// false only for legacy interop scenarios. Forwarded to /// SetRejectSHA1SignedCertificates. /// public bool RejectSHA1Certificates { get; set; } = true; /// /// Minimum accepted certificate RSA key size during validation. /// Defaults to 2048; set to 0 to keep the stack default. /// Forwarded to SetMinimumCertificateKeySize. /// public ushort MinCertificateKeySize { get; set; } = 2048; /// /// Optional URL of an LDS/GDS registration endpoint. When set, the /// hosted service builds a minimal /// and forwards it to /// SetRegistrationEndpoint so the server registers itself /// with the configured discovery server on startup. /// public string? RegistrationEndpointUrl { get; set; } /// /// Server-side reverse-connect configuration. When non-null the /// hosted service builds the equivalent /// and forwards it /// to SetReverseConnect. /// public ServerReverseConnectOptions? ReverseConnect { get; set; } /// /// Operation limits advertised by the server (max nodes per read, /// write, browse, etc.). When non-null the hosted service projects /// the value into and forwards it to /// SetOperationLimits. /// public OperationLimitsOptions? OperationLimits { get; set; } /// /// Optional escape hatch invoked after the standard configuration steps /// (transport quotas, server policies, security configuration) but /// before CreateAsync. Use it to add bespoke security policies, /// override quotas, or add custom security stores. /// public Action? ConfigureBuilder { get; set; } } }