/* ======================================================================== * 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 Microsoft.Extensions.DependencyInjection; using Opc.Ua.Configuration; #nullable enable namespace Opc.Ua.Lds.Server.Hosting { /// /// Options for an OPC UA Local Discovery Server (LDS / LDS-ME) 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 LdsServerOptions { /// /// 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; } = "LdsServer"; /// /// Application URI (e.g. urn:localhost:UA:LocalDiscoveryServer). /// Required. /// public string ApplicationUri { get; set; } = string.Empty; /// /// Product URI (e.g. uri:opcfoundation.org:LocalDiscoveryServer). /// Required. /// 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. Per OPC 10000-12 the canonical LDS endpoint is /// opc.tcp://{host}:4840; tests typically use ephemeral ports. /// 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; } /// /// When true (the default) and the platform supports it, the /// hosted LDS announces itself via mDNS (LDS-ME, OPC 10000-12 ยง6.4.6) /// using . Disable on platforms /// without multicast support or in test environments. /// public bool EnableMulticast { get; set; } = true; /// /// Restrict the multicast announcer to the loopback NIC. Intended /// for in-process tests where the LDS-ME traffic must stay local. /// Ignored when is false. /// public bool MulticastLoopbackOnly { get; set; } /// /// Extra server capabilities to advertise. Each entry is appended /// via IApplicationConfigurationBuilderServerOptions.AddServerCapabilities /// and surfaces in . /// The hosted LDS always adds LDS (and LDS-ME when /// multicast is enabled) per OPC 10000-12 Annex D; entries here are /// additive. Mutated in place by /// options.ServerCapabilities.Add(...). /// public IList ServerCapabilities { get; } = []; /// /// 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; } } }