Exemplo n.º 1
0
        /// <summary>
        /// Convert to transport quota
        /// </summary>
        /// <param name="transportQuotaConfig"></param>
        /// <returns></returns>
        public static TransportQuotas ToTransportQuotas(this ITransportQuotaConfig transportQuotaConfig)
        {
            var transportQuotas = new TransportQuotas {
                OperationTimeout      = transportQuotaConfig.OperationTimeout,
                MaxStringLength       = transportQuotaConfig.MaxStringLength,
                MaxByteStringLength   = transportQuotaConfig.MaxByteStringLength,
                MaxArrayLength        = transportQuotaConfig.MaxArrayLength,
                MaxMessageSize        = transportQuotaConfig.MaxMessageSize,
                MaxBufferSize         = transportQuotaConfig.MaxBufferSize,
                ChannelLifetime       = transportQuotaConfig.ChannelLifetime,
                SecurityTokenLifetime = transportQuotaConfig.SecurityTokenLifetime
            };

            return(transportQuotas);
        }
 /// <inheritdoc/>
 public IApplicationConfigurationBuilderTransportQuotasSet SetTransportQuotas(TransportQuotas transportQuotas)
 {
     ApplicationConfiguration.TransportQuotas = transportQuotas;
     return(this);
 }
        public async Task LoadClientConfiguration(int port = -1)
        {
            ApplicationInstance.MessageDlg = new ApplicationMessageDlg();
            ApplicationInstance application = new ApplicationInstance {
                ApplicationName   = "Server Configuration Push Test Client",
                ApplicationType   = ApplicationType.Client,
                ConfigSectionName = "Opc.Ua.ServerConfigurationPushTestClient"
            };

#if USE_FILE_CONFIG
            // load the application configuration.
            Config = await application.LoadApplicationConfiguration(false).ConfigureAwait(false);
#else
            string root         = Path.Combine("%LocalApplicationData%", "OPC");
            string pkiRoot      = Path.Combine(root, "pki");
            var    clientConfig = new ServerConfigurationPushTestClientConfiguration()
            {
                ServerUrl        = "opc.tcp://localhost:58810/GlobalDiscoveryTestServer",
                AppUserName      = "",
                AppPassword      = "",
                SysAdminUserName = "******",
                SysAdminPassword = "******",
                TempStorePath    = Path.Combine(pkiRoot, "temp")
            };

            var transportQuotas = new TransportQuotas()
            {
                OperationTimeout      = 120000,
                MaxStringLength       = 1048576,
                MaxByteStringLength   = 1048576,
                MaxArrayLength        = 65535,
                MaxMessageSize        = 4194304,
                MaxBufferSize         = 65535,
                ChannelLifetime       = 300000,
                SecurityTokenLifetime = 3600000,
            };

            // build the application configuration.
            Config = await application
                     .Build(
                "urn:localhost:opcfoundation.org:ServerConfigurationPushTestClient",
                "http://opcfoundation.org/UA/ServerConfigurationPushTestClient")
                     .SetTransportQuotas(transportQuotas)
                     .AsClient()
                     .AddSecurityConfiguration(
                "CN=Server Configuration Push Test Client, O=OPC Foundation",
                pkiRoot)
                     .SetAutoAcceptUntrustedCertificates(true)
                     .SetRejectSHA1SignedCertificates(false)
                     .SetRejectUnknownRevocationStatus(true)
                     .SetMinimumCertificateKeySize(1024)
                     .AddExtension <ServerConfigurationPushTestClientConfiguration>(null, clientConfig)
                     .SetOutputFilePath(pkiRoot + "/Logs/Opc.Ua.Gds.Tests.log.txt")
                     .SetTraceMasks(Utils.TraceMasks.Error)
                     .Create().ConfigureAwait(false);
#endif
            // check the application certificate.
            bool haveAppCertificate = await application.CheckApplicationInstanceCertificate(true, 0).ConfigureAwait(false);

            if (!haveAppCertificate)
            {
                throw new Exception("Application instance certificate invalid!");
            }

            Config.CertificateValidator.CertificateValidation += new CertificateValidationEventHandler(CertificateValidator_CertificateValidation);

            ServerConfigurationPushTestClientConfiguration clientConfiguration = application.ApplicationConfiguration.ParseExtension <ServerConfigurationPushTestClientConfiguration>();
            _client = new ServerPushConfigurationClient(application)
            {
                EndpointUrl = TestUtils.PatchOnlyGDSEndpointUrlPort(clientConfiguration.ServerUrl, port)
            };
            if (String.IsNullOrEmpty(clientConfiguration.AppUserName))
            {
                AppUser = new UserIdentity(new AnonymousIdentityToken());
            }
            else
            {
                AppUser = new UserIdentity(clientConfiguration.AppUserName, clientConfiguration.AppPassword);
            }
            SysAdminUser  = new UserIdentity(clientConfiguration.SysAdminUserName, clientConfiguration.SysAdminPassword);
            TempStorePath = clientConfiguration.TempStorePath;
        }
Exemplo n.º 4
0
        static void callMethod()
        {
            EndpointConfiguration ec = new EndpointConfiguration();
            EndpointDescription   endpointDescription = new EndpointDescription("opc.tcp://localhost:58710/PCoUaServer");

            configuredEndpoint = new ConfiguredEndpoint(new ConfiguredEndpointCollection(), endpointDescription);
            configuredEndpoint.Configuration.UseBinaryEncoding = true;
            configuredEndpoint.Description.UserIdentityTokens.Add(new UserTokenPolicy(UserTokenType.Anonymous));

            applicationConfiguration = new ApplicationConfiguration();
            applicationConfiguration.ApplicationType = ApplicationType.Client;
            applicationConfiguration.ApplicationName = "SAPClientSession";
            applicationConfiguration.ApplicationUri  = "SAPClientSession";
            SecurityConfiguration secConfig = new SecurityConfiguration();

            secConfig.ApplicationCertificate = GetPCoDefaultCertificate();
            applicationConfiguration.SecurityConfiguration = secConfig;
            TransportQuotas transportQuotas = new TransportQuotas();

            applicationConfiguration.TransportQuotas = transportQuotas;
            ClientConfiguration clientConfiguration = new ClientConfiguration();

            applicationConfiguration.ClientConfiguration = clientConfiguration;
            applicationConfiguration.Validate(ApplicationType.Client);

            CertificateValidationOptions certOptions = applicationConfiguration.SecurityConfiguration.TrustedPeerCertificates.ValidationOptions;

            certOptions |= CertificateValidationOptions.SuppressCertificateExpired;
            certOptions |= CertificateValidationOptions.SuppressHostNameInvalid;

            securelyUpdateEndpointConfiguration(configuredEndpoint, applicationConfiguration);
            applicationConfiguration.CertificateValidator.CertificateValidation += CertificateValidator_CertificateValidation;

            clientSession = Session.Create(
                applicationConfiguration,
                configuredEndpoint,
                false, false,
                sessionName,
                sessionTimeout,
                identity,
                null, null);

            clientSession.ReturnDiagnostics = DiagnosticsMasks.All;

            clientSession.KeepAliveInterval = 2 * 1000;

            try
            {
                int maxNodesPerReadRuntimeInformation = Convert.ToInt32(clientSession.ReadValue(Opc.Ua.VariableIds.Server_ServerCapabilities_OperationLimits_MaxNodesPerRead).Value);
                //if (tracer.Switch.ShouldTrace(TraceEventType.Verbose))
                {
                    String message = String.Format("Retrieved operation limits for reading ({0}) from server", maxNodesPerReadRuntimeInformation);
                    //TraceUtility.LogData(tracer, TraceUtility.EventId.E2718, TraceEventType.Verbose, message);
                }
            }
            catch (Exception)
            {
                // the value is not supplied or an error occured.
                {
                    String message = String.Format("Could not retrieve operation limits for reading from server");
                }
            }

            //NodeId nodeiD = clientSession.ReadNode();
            var v11 = clientSession.Call((NodeId)("ns=2;s=348259fa-527e-4d5e-bde1-f5e1ccf01d61"), (NodeId)("ns=2;s=aef01ad4-3fe3-4836-83d0-cc808735f530"), new object[] { });

            //BrowseResultCollection browseResultCollection;
            //DiagnosticInfoCollection diagnosticInfos;
            //NodeId currentNode = FindCurrentNode(null, clientSession, configuredEndpoint);
            //uint nodeClassMask = (uint)(NodeClass.Object | NodeClass.Method);
            //BrowseDescriptionCollection nodesToBrowse = PrepareBrowseDescriptionCollection(currentNode, nodeClassMask);
            //clientSession.Browse(
            //        null,
            //        null,
            //        100,
            //        nodesToBrowse,
            //        out browseResultCollection,
            //        out diagnosticInfos);

            //var app_Base_To_method = clientSession.ReadNode((NodeId)(browseResultCollection[0].References[1].NodeId.ToString()));

            //ClientBase.ValidateResponse(browseResultCollection, nodesToBrowse);
            //ClientBase.ValidateDiagnosticInfos(diagnosticInfos, nodesToBrowse);
            //ReferenceDescriptionCollection references;

            ////int resultLength = 0;

            //foreach (BrowseResult br in browseResultCollection)
            //{
            //    /// TODO: Store the continuation point as member of UaBrowser (new class) and
            //    /// use it when we are called with BrowseNext mode.
            //    byte[] continuationPoint = br.ContinuationPoint;
            //    while (continuationPoint != null)
            //    {
            //        byte[] revisedContinuationPoint;
            //        ResponseHeader rc = clientSession.BrowseNext(
            //            null,
            //            false,
            //            continuationPoint,
            //            out revisedContinuationPoint,
            //            out references);
            //        br.References.AddRange(references);
            //        //resultLength += br.References.Count;
            //        if (br.References.Count >= 100)
            //        {
            //            //int removeCount = br.References.Count - maxRows;
            //            br.References.RemoveRange((int)100, (int)br.References.Count - (int)100);
            //            continuationPoint = revisedContinuationPoint;
            //            if (continuationPoint != null)
            //            {
            //                // release continuation point on server
            //                rc = clientSession.BrowseNext(
            //                        null,
            //                        true, // <- release cp
            //                        continuationPoint,
            //                        out revisedContinuationPoint,
            //                        out references);
            //            }
            //            break;

            //        }
            //        continuationPoint = revisedContinuationPoint;
            //    }
            //}

            ////ns=2;s=a72e725d-6be7-4a17-bcd4-0be67b6cbfbe
            ////browseResultCollection[0].References[1].NodeId;


            //var vrere = clientSession.ReadNode((NodeId)("ns=2;s=50bcabac-623b-43ea-8f69-17b12d533166"));

            //nodesToBrowse = PrepareBrowseDescriptionCollection
            //    ((NodeId)(browseResultCollection[0].References[1].NodeId.ToString()), nodeClassMask);
            //clientSession.Browse(
            //        null,
            //        null,
            //        100,
            //        nodesToBrowse,
            //        out browseResultCollection,
            //        out diagnosticInfos);

            //var application_method = clientSession.ReadNode((NodeId)(browseResultCollection[1].References[0].NodeId.ToString()));
            //var v1 = clientSession.FetchReferences((NodeId)(browseResultCollection[1].References[0].NodeId.ToString()));
            ////var v2 = clientSession.ReadValue((NodeId)(browseResultCollection[1].References[0].NodeId.ToString()));

            //nodesToBrowse = PrepareBrowseDescriptionCollection
            //    ((NodeId)(browseResultCollection[1].References[0].NodeId.ToString()), nodeClassMask);
            //clientSession.Browse(null, null, 100, nodesToBrowse, out browseResultCollection, out diagnosticInfos);

            //var v = clientSession.ReadNode((NodeId)(browseResultCollection[5].References[0].NodeId.ToString()));
            //v1 = clientSession.FetchReferences((NodeId)(browseResultCollection[5].References[0].NodeId.ToString()));
            ////v2 = clientSession.ReadValue((NodeId)(browseResultCollection[5].References[0].NodeId.ToString()));


            ////TypeInfo.GetSystemType(dataType, clientSession.Factory);
            //nodeClassMask = (uint)(NodeClass.Object | NodeClass.Method | NodeClass.View |
            //    NodeClass.VariableType | NodeClass.Variable | NodeClass.ObjectType);
            //nodesToBrowse = PrepareBrowseDescriptionCollection
            //    ((NodeId)(browseResultCollection[5].References[0].NodeId.ToString()), nodeClassMask);
            //var v5 = clientSession.ReadNode((NodeId)(browseResultCollection[5].References[0].NodeId.ToString()));
            //clientSession.Browse(null, null, 100, nodesToBrowse, out browseResultCollection, out diagnosticInfos);


            //BrowsePathCollection pathsToArgs = new BrowsePathCollection();

            //BrowsePath pathToInputArgs = new BrowsePath();
            //pathToInputArgs.StartingNode = application_method.NodeId;
            //pathToInputArgs.RelativePath = new RelativePath(ReferenceTypeIds.HasProperty, false, true, new QualifiedName("InputArguments"));

            //pathsToArgs.Add(pathToInputArgs);

            //BrowsePath pathToOutputArgs = new BrowsePath();
            //pathToOutputArgs.StartingNode = application_method.NodeId;
            //pathToOutputArgs.RelativePath = new RelativePath(ReferenceTypeIds.HasProperty, false, true, new QualifiedName("OutputArguments"));

            //pathsToArgs.Add(pathToOutputArgs);

            //BrowsePathResultCollection results = null;
            //// Get the nodeId of the input argument
            //ResponseHeader responseHeader = clientSession.TranslateBrowsePathsToNodeIds(
            //    null,
            //    pathsToArgs,
            //    out results,
            //    out diagnosticInfos
            //    );

            //ArgumentCollection[] arguments = new ArgumentCollection[2];
            //for (int i = 0; i < 2; i++)
            //{
            //    arguments[i] = new ArgumentCollection();
            //    foreach (BrowsePathTarget bptarget in results[i].Targets)
            //    {
            //        DataValueCollection readResults = null;

            //        ReadValueId nodeToRead = new ReadValueId();
            //        nodeToRead.NodeId = (NodeId)bptarget.TargetId;
            //        nodeToRead.AttributeId = Attributes.Value;
            //        ReadValueIdCollection nodesToRead = new ReadValueIdCollection();
            //        nodesToRead.Add(nodeToRead);

            //        DiagnosticInfoCollection readDiagnoistcInfos = null;

            //        clientSession.Read(
            //            null,
            //            0,
            //            TimestampsToReturn.Neither,
            //            nodesToRead,
            //            out readResults,
            //            out readDiagnoistcInfos
            //            );

            //        ExtensionObject[] exts = (ExtensionObject[])readResults[0].Value;
            //        for (int j = 0; j < exts.Length; ++j)
            //        {
            //            ExtensionObject ext = exts[j];
            //            arguments[i].Add((Argument)ext.Body);
            //        }

            //    }
            //}
            // establish keep-alive
            //clientSession.KeepAlive += new KeepAliveEventHandler(clientSession_KeepAlive);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Main
        /// </summary>
        /// <param name="args"></param>
        public static void Main(string[] args)
        {
            Console.WriteLine("Starting LightLDS - The lightweight OPC UA Local Discovery Server");

            ApplicationInstance application = new ApplicationInstance();

            try
            {
                var applicationConfiguration = new ApplicationConfiguration();
                applicationConfiguration.ApplicationName = "Light OPC UA Local Discovery Server";
                applicationConfiguration.ApplicationUri  = "urn:localhost:K47S:LocalDiscoveryServer";
                applicationConfiguration.ProductUri      = "http://K47S/LocalDiscoveryServer";
                applicationConfiguration.ApplicationType = ApplicationType.DiscoveryServer;

                var securityConfiguration = new SecurityConfiguration();
                securityConfiguration.ApplicationCertificate = new CertificateIdentifier()
                {
                    StoreType   = @"Directory",
                    StorePath   = @"%CommonApplicationData%/LightLDS/PKI/own",
                    SubjectName = "CN=Local Discovery Server, O=K47S, DC=localhost",
                };
                securityConfiguration.TrustedIssuerCertificates = new CertificateTrustList()
                {
                    StoreType = @"Directory",
                    StorePath = @"%CommonApplicationData%/LightLDS/PKI/issuers",
                };
                securityConfiguration.TrustedPeerCertificates = new CertificateTrustList()
                {
                    StoreType = @"Directory",
                    StorePath = @"%CommonApplicationData%/LightLDS/PKI/trusted",
                };
                securityConfiguration.RejectedCertificateStore = new CertificateTrustList()
                {
                    StoreType = @"Directory",
                    StorePath = @"%CommonApplicationData%/LightLDS/PKI/rejected",
                };
                securityConfiguration.AutoAcceptUntrustedCertificates = true;
                securityConfiguration.RejectSHA1SignedCertificates    = false;
                securityConfiguration.MinimumCertificateKeySize       = 1024;
                applicationConfiguration.SecurityConfiguration        = securityConfiguration;

                var serverConfiguration = new ServerConfiguration();
                serverConfiguration.BaseAddresses = new StringCollection(new List <string>()
                {
                    "opc.tcp://localhost:4840"
                });
                serverConfiguration.SecurityPolicies = new ServerSecurityPolicyCollection(new List <ServerSecurityPolicy>()
                {
                    new ServerSecurityPolicy()
                    {
                        SecurityMode      = MessageSecurityMode.None,
                        SecurityPolicyUri = "http://opcfoundation.org/UA/SecurityPolicy#None",
                    }
                });
                serverConfiguration.UserTokenPolicies = new UserTokenPolicyCollection(new List <UserTokenPolicy>()
                {
                    new UserTokenPolicy()
                    {
                        TokenType         = UserTokenType.Anonymous,
                        SecurityPolicyUri = "http://opcfoundation.org/UA/SecurityPolicy#None"
                    }
                });
                serverConfiguration.DiagnosticsEnabled           = true;
                serverConfiguration.MaxSessionCount              = 100;
                serverConfiguration.MinSessionTimeout            = 10000;
                serverConfiguration.MaxSessionTimeout            = 3600000;
                serverConfiguration.MaxBrowseContinuationPoints  = 10;
                serverConfiguration.MaxQueryContinuationPoints   = 10;
                serverConfiguration.MaxHistoryContinuationPoints = 100;
                serverConfiguration.MaxRequestAge               = 600000;
                serverConfiguration.MinPublishingInterval       = 100;
                serverConfiguration.MaxPublishingInterval       = 3600000;
                serverConfiguration.PublishingResolution        = 100;
                serverConfiguration.MaxSubscriptionLifetime     = 3600000;
                serverConfiguration.MaxMessageQueueSize         = 100;
                serverConfiguration.MaxNotificationQueueSize    = 100;
                serverConfiguration.MaxNotificationsPerPublish  = 1000;
                serverConfiguration.MinMetadataSamplingInterval = 1000;
                applicationConfiguration.ServerConfiguration    = serverConfiguration;

                var transportQuotaConfig = new TransportQuotas();
                applicationConfiguration.TransportQuotas = transportQuotaConfig;

                var traceConfiguration = new TraceConfiguration();
                traceConfiguration.OutputFilePath           = "%CommonApplicationData%/LightLDS/Logs/LocalDiscoveryServer.log.txt";
                traceConfiguration.DeleteOnLoad             = true;
                traceConfiguration.TraceMasks               = 0x7FFFFFFF;
                applicationConfiguration.TraceConfiguration = traceConfiguration;

                application.ApplicationConfiguration = applicationConfiguration;
                application.ApplicationConfiguration.Validate(ApplicationType.Server);
                // check the application certificate.
                application.CheckApplicationInstanceCertificate(false, 0).Wait();

                // start the server.
                var server = new DiscoveryServerInstance();
                application.Start(server).Wait();

                Console.WriteLine("LightLDS running. Press ENTER to exit.");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            Console.ReadLine();
        }
Exemplo n.º 6
0
        public static void connectToOPCUAServer(String opcuaServerUrl)
        {
            #region SessionConfiguration
            EndpointConfiguration ec = new EndpointConfiguration();
            EndpointDescription   endpointDescription = new EndpointDescription(opcuaServerUrl);
            configuredEndpoint = new ConfiguredEndpoint(new ConfiguredEndpointCollection(), endpointDescription);
            configuredEndpoint.Configuration.UseBinaryEncoding = true;
            configuredEndpoint.Description.UserIdentityTokens.Add(new UserTokenPolicy(UserTokenType.Anonymous));

            applicationConfiguration = new ApplicationConfiguration();
            applicationConfiguration.ApplicationType = ApplicationType.Client;
            applicationConfiguration.ApplicationName = "SAPClientSession";
            applicationConfiguration.ApplicationUri  = "SAPClientSession";
            SecurityConfiguration secConfig = new SecurityConfiguration();
            secConfig.ApplicationCertificate = GetPCoDefaultCertificate();
            applicationConfiguration.SecurityConfiguration = secConfig;
            TransportQuotas transportQuotas = new TransportQuotas();
            applicationConfiguration.TransportQuotas = transportQuotas;
            ClientConfiguration clientConfiguration = new ClientConfiguration();
            applicationConfiguration.ClientConfiguration = clientConfiguration;
            applicationConfiguration.Validate(ApplicationType.Client);

            CertificateValidationOptions certOptions = applicationConfiguration.SecurityConfiguration.TrustedPeerCertificates.ValidationOptions;
            certOptions |= CertificateValidationOptions.SuppressCertificateExpired;
            certOptions |= CertificateValidationOptions.SuppressHostNameInvalid;

            securelyUpdateEndpointConfiguration(configuredEndpoint, applicationConfiguration);
            applicationConfiguration.CertificateValidator.CertificateValidation += CertificateValidator_CertificateValidation;

            clientSession = Session.Create(
                applicationConfiguration,
                configuredEndpoint,
                false, false,
                sessionName,
                sessionTimeout,
                identity,
                null, null);

            clientSession.ReturnDiagnostics = DiagnosticsMasks.All;

            clientSession.KeepAliveInterval = 2 * 1000;

            try
            {
                int maxNodesPerReadRuntimeInformation = Convert.ToInt32(clientSession.ReadValue(Opc.Ua.VariableIds.Server_ServerCapabilities_OperationLimits_MaxNodesPerRead).Value);
                //if (tracer.Switch.ShouldTrace(TraceEventType.Verbose))
                {
                    String message = String.Format("Retrieved operation limits for reading ({0}) from server", maxNodesPerReadRuntimeInformation);
                    //TraceUtility.LogData(tracer, TraceUtility.EventId.E2718, TraceEventType.Verbose, message);
                }
            }
            catch (Exception)
            {
                // the value is not supplied or an error occured.
                {
                    String message = String.Format("Could not retrieve operation limits for reading from server");
                }
            }

            #endregion
            opcuaNodeStructure.ChildrenNodes = new List <OpcuaNodeLink>();

            //Add root node
            OpcuaNodeLink opcuaNodeLink = new OpcuaNodeLink();
            opcuaNodeLink.nodeID               = FindCurrentNode(null, clientSession, configuredEndpoint).ToString();
            opcuaNodeLink.browseName           = "AddressRoot";
            opcuaNodeLink.parentNodeId         = String.Empty;
            opcuaNodeLink.parentNodebrowseName = String.Empty;
            opcuaNodeLink.isMethod             = opcuaNodeLink.isArgument = false;
            opcuaNodeStructure.ChildrenNodes.Add(opcuaNodeLink);

            BrowseNode(FindCurrentNode(null, clientSession, configuredEndpoint).ToString(), opcuaNodeLink.browseName);
        }
Exemplo n.º 7
0
        /// <summary>
        /// hardcoded application configuration of the collector server/client
        /// </summary>
        /// <returns>application configuration of the collector server/client</returns>
        public static ApplicationConfiguration getConfiguration()
        {
            //not fully implemented

            ApplicationConfiguration config = new ApplicationConfiguration();

            config.ApplicationName = "Collector Server";
            //config.ApplicationType = null;
            config.ApplicationUri = @"urn:localhost:UA:InformationModelServer";
            //config.CertificateValidator = null;
            //config.ClientConfiguration = null;
            //config.DisableHiResClock = null;
            //config.DiscoveryServerConfiguration = null;
            #region Extensions
            List <XmlElement> config_extensions = new List <XmlElement>();

            #endregion
            config.Extensions = new XmlElementCollection();
            //config.MessageContext = null;
            config.ProductUri = @"http://opcfoundation.org/UA/InformationModelServer";
            //config.Properties = null;
            //config.PropertiesLock = null;
            #region Security Configuration
            SecurityConfiguration config_security             = new SecurityConfiguration();
            CertificateIdentifier config_security_certificate = new CertificateIdentifier();
            config_security_certificate.StoreType   = "Directory";
            config_security_certificate.StorePath   = @"%CommonApplicationData%\OPC Foundation\pki\own";
            config_security_certificate.SubjectName = @"CN = Demo Server, C = US, S = Arizona, O = OPC Foundation, DC = localhost";
            config_security.ApplicationCertificate  = config_security_certificate;
            CertificateTrustList config_trustedIssuer = new CertificateTrustList();
            config_trustedIssuer.StoreType            = "Directory";
            config_trustedIssuer.StorePath            = @"%CommonApplicationData%\OPC Foundation\pki\issuer";
            config_security.TrustedIssuerCertificates = config_trustedIssuer;
            CertificateTrustList config_security_trustedPeer = new CertificateTrustList();
            config_security_trustedPeer.StoreType   = "Directory";
            config_security_trustedPeer.StorePath   = @"%CommonApplicationData%\OPC Foundation\pki\trusted";
            config_security.TrustedPeerCertificates = config_security_trustedPeer;
            CertificateStoreIdentifier config_security_rejected = new CertificateStoreIdentifier();
            config_security_rejected.StoreType       = "Directory";
            config_security_rejected.StorePath       = @"%CommonApplicationData%\OPC Foundation\pki\rejected";
            config_security.RejectedCertificateStore = config_security_rejected;
            #endregion
            config.SecurityConfiguration = config_security;
            //config_security.ApplicationCertificate = null;
            #region ServerConfiguration
            ServerConfiguration config_server            = new ServerConfiguration();
            List <string>       config_server_baseAdress = new List <string>();
            config_server_baseAdress.Add(@"https://*****:*****@"opc.tcp://localhost:51210/CollectorServer");
            config_server.BaseAddresses = new StringCollection(config_server_baseAdress);
            List <ServerSecurityPolicy> config_server_policies = new List <ServerSecurityPolicy>();
            ServerSecurityPolicy        tmp_pol1 = new ServerSecurityPolicy();
            tmp_pol1.SecurityMode      = MessageSecurityMode.SignAndEncrypt;
            tmp_pol1.SecurityPolicyUri = @"http://opcfoundation.org/UA/SecurityPolicy#Basic256Sha256";
            config_server_policies.Add(tmp_pol1);
            ServerSecurityPolicy tmp_pol2 = new ServerSecurityPolicy();
            tmp_pol2.SecurityMode      = MessageSecurityMode.None;
            tmp_pol2.SecurityPolicyUri = @"http://opcfoundation.org/UA/SecurityPolicy#None";
            config_server_policies.Add(tmp_pol2);
            ServerSecurityPolicy tmp_pol3 = new ServerSecurityPolicy();
            tmp_pol3.SecurityMode      = MessageSecurityMode.Sign;
            tmp_pol3.SecurityPolicyUri = @"";
            config_server_policies.Add(tmp_pol3);
            ServerSecurityPolicy tmp_pol4 = new ServerSecurityPolicy();
            tmp_pol4.SecurityMode      = MessageSecurityMode.SignAndEncrypt;
            tmp_pol4.SecurityPolicyUri = @"";
            ServerSecurityPolicyCollection config_server_policy = new ServerSecurityPolicyCollection(config_server_policies);
            config_server.SecurityPolicies = config_server_policy;
            List <UserTokenPolicy> config_server_userTokenPolicies = new List <UserTokenPolicy>();
            config_server_userTokenPolicies.Add(new UserTokenPolicy(UserTokenType.Anonymous));
            config_server_userTokenPolicies.Add(new UserTokenPolicy(UserTokenType.UserName));
            config_server_userTokenPolicies.Add(new UserTokenPolicy(UserTokenType.Certificate));
            config_server.UserTokenPolicies            = new UserTokenPolicyCollection(config_server_userTokenPolicies);
            config_server.DiagnosticsEnabled           = false;
            config_server.MaxSessionCount              = 100;
            config_server.MinSessionTimeout            = 10000;
            config_server.MaxSessionTimeout            = 3600000;
            config_server.MaxBrowseContinuationPoints  = 10;
            config_server.MaxQueryContinuationPoints   = 10;
            config_server.MaxHistoryContinuationPoints = 100;
            config_server.MaxRequestAge               = 600000;
            config_server.MinPublishingInterval       = 100;
            config_server.MaxPublishingInterval       = 3600000;
            config_server.PublishingResolution        = 50;
            config_server.MaxSubscriptionLifetime     = 3600000;
            config_server.MaxMessageQueueSize         = 10;
            config_server.MaxNotificationQueueSize    = 100;
            config_server.MaxNotificationsPerPublish  = 1000;
            config_server.MinMetadataSamplingInterval = 1000;
            List <SamplingRateGroup> config_server_samplingRateGroups = new List <SamplingRateGroup>();
            config_server_samplingRateGroups.Add(new SamplingRateGroup(5, 5, 20));
            config_server_samplingRateGroups.Add(new SamplingRateGroup(100, 100, 4));
            config_server_samplingRateGroups.Add(new SamplingRateGroup(500, 250, 2));
            config_server_samplingRateGroups.Add(new SamplingRateGroup(1000, 500, 20));
            config_server.AvailableSamplingRates  = new SamplingRateGroupCollection(config_server_samplingRateGroups);
            config_server.MaxRegistrationInterval = 30000;
            #endregion
            config.ServerConfiguration = config_server;
            //config.SourceFilePath = null;
            #region TraceConfiguration
            TraceConfiguration config_traceConfiguration = new TraceConfiguration();
            config_traceConfiguration.OutputFilePath = @"Logs\Quickstarts.BoilerServer.log.txt";
            config_traceConfiguration.DeleteOnLoad   = true;
            config_traceConfiguration.TraceMasks     = 515;
            #endregion
            config.TraceConfiguration      = config_traceConfiguration;
            config.TransportConfigurations = new TransportConfigurationCollection();
            #region TransportQuotas
            TransportQuotas config_transportQuotas = new TransportQuotas();
            config_transportQuotas.OperationTimeout      = 600000;
            config_transportQuotas.MaxStringLength       = 1048576;
            config_transportQuotas.MaxByteStringLength   = 1048576;
            config_transportQuotas.MaxArrayLength        = 65535;
            config_transportQuotas.ChannelLifetime       = 300000;
            config_transportQuotas.SecurityTokenLifetime = 3600000;
            #endregion
            config.TransportQuotas = config_transportQuotas;
            return(config);
        }