/* ========================================================================
* Copyright (c) 2005-2026 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.Gds.Server.Hosting
{
///
/// Options for an OPC UA Global Discovery Server (GDS) hosted by
/// the .NET Generic Host via
/// .
///
///
///
/// Mirrors OpcUaServerOptions for the standard server feature
/// and adds GDS-specific knobs that populate the
/// extension attached
/// to the underlying .
///
///
/// Only the most common knobs are exposed directly. Use
/// for full control of the underlying
/// chain (security
/// policies, transport quotas, custom security stores, additional
/// configuration extensions, etc.).
///
///
public sealed class GdsServerOptions
{
///
/// 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; } = "GlobalDiscoveryServer";
///
/// Application URI (e.g. urn:localhost:OPCFoundation:GDS).
///
public string ApplicationUri { get; set; } = string.Empty;
///
/// Product URI (e.g. http://opcfoundation.org/UA/GDS).
///
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; }
///
/// Whether new certificate requests are auto-approved.
/// Convenient for quickstart samples; do not enable in
/// production.
///
public bool AutoApprove { get; set; } = true;
///
/// Filesystem path for the trusted CA Authorities store.
/// When empty, defaults to {PkiRoot}/CA/authorities.
///
public string AuthoritiesStorePath { get; set; } = string.Empty;
///
/// Filesystem path for the registered Applications certificate
/// store. When empty, defaults to {PkiRoot}/applications.
///
public string ApplicationCertificatesStorePath { get; set; } = string.Empty;
///
/// Filesystem path used as the base for the default certificate
/// group's CA. When empty, defaults to {PkiRoot}/CA.
///
public string BaseCertificateGroupStorePath { get; set; } = string.Empty;
///
/// Default subject-name suffix appended to certificates issued
/// by this GDS (e.g. ,O=OPC Foundation,DC=localhost).
///
public string DefaultSubjectNameContext { get; set; } = string.Empty;
///
/// Optional escape hatch invoked after the standard
/// configuration steps (transport quotas, server policies,
/// security configuration, GDS extension) but before
/// CreateAsync. Use it to add bespoke security policies,
/// override quotas, or add custom security stores.
///
public Action? ConfigureBuilder { get; set; }
}
}