diff --git a/Libraries/Opc.Ua.Configuration/ApplicationConfigurationBuilder.cs b/Libraries/Opc.Ua.Configuration/ApplicationConfigurationBuilder.cs index 5d95bc5312..72eac76f9f 100644 --- a/Libraries/Opc.Ua.Configuration/ApplicationConfigurationBuilder.cs +++ b/Libraries/Opc.Ua.Configuration/ApplicationConfigurationBuilder.cs @@ -247,7 +247,8 @@ namespace Opc.Ua.Configuration { if (addPolicy) { - AddSecurityPolicies(false, false, true); + var policies = ApplicationConfiguration.ServerConfiguration.SecurityPolicies; + InternalAddPolicy(policies, MessageSecurityMode.None, SecurityPolicies.None); } return this; } diff --git a/Stack/Opc.Ua.Bindings.Https/Stack/Https/HttpsTransportChannel.cs b/Stack/Opc.Ua.Bindings.Https/Stack/Https/HttpsTransportChannel.cs index f68b8b8bc0..1de947d613 100644 --- a/Stack/Opc.Ua.Bindings.Https/Stack/Https/HttpsTransportChannel.cs +++ b/Stack/Opc.Ua.Bindings.Https/Stack/Https/HttpsTransportChannel.cs @@ -116,14 +116,19 @@ namespace Opc.Ua.Bindings // auto validate server cert, if supported // if unsupported, the TLS server cert must be trusted by a root CA - var handler = new HttpClientHandler - { + var handler = new HttpClientHandler { ClientCertificateOptions = ClientCertificateOption.Manual, - MaxConnectionsPerServer = kMaxConnectionsPerServer, AllowAutoRedirect = false, MaxRequestContentBufferSize = m_quotas.MaxMessageSize, }; + // set property only if supported + var maxConnectionsPerServerProperty = handler.GetType().GetProperty("MaxConnectionsPerServer"); + if (maxConnectionsPerServerProperty != null) + { + maxConnectionsPerServerProperty.SetValue(handler, kMaxConnectionsPerServer); + } + // send client certificate for servers that require TLS client authentication if (m_settings.ClientCertificate != null) { @@ -148,8 +153,7 @@ namespace Opc.Ua.Bindings try { serverCertificateCustomValidationCallback = - (httpRequestMessage, cert, chain, policyErrors) => - { + (httpRequestMessage, cert, chain, policyErrors) => { try { var validationChain = new X509Certificate2Collection(); @@ -246,8 +250,7 @@ namespace Opc.Ua.Bindings } var result = new HttpsAsyncResult(callback, callbackData, m_operationTimeout, request, null); - Task.Run(async () => - { + Task.Run(async () => { try { var ct = new CancellationTokenSource(m_operationTimeout).Token; @@ -416,15 +419,13 @@ namespace Opc.Ua.Bindings m_operationTimeout = settings.Configuration.OperationTimeout; // initialize the quotas. - m_quotas = new ChannelQuotas - { + m_quotas = new ChannelQuotas { MaxBufferSize = m_settings.Configuration.MaxBufferSize, MaxMessageSize = m_settings.Configuration.MaxMessageSize, ChannelLifetime = m_settings.Configuration.ChannelLifetime, SecurityTokenLifetime = m_settings.Configuration.SecurityTokenLifetime, - MessageContext = new ServiceMessageContext - { + MessageContext = new ServiceMessageContext { MaxArrayLength = m_settings.Configuration.MaxArrayLength, MaxByteStringLength = m_settings.Configuration.MaxByteStringLength, MaxMessageSize = m_settings.Configuration.MaxMessageSize, diff --git a/Stack/Opc.Ua.Core/Stack/Client/DiscoveryClient.cs b/Stack/Opc.Ua.Core/Stack/Client/DiscoveryClient.cs index 24ed8cdf12..2cc0dd3c36 100644 --- a/Stack/Opc.Ua.Core/Stack/Client/DiscoveryClient.cs +++ b/Stack/Opc.Ua.Core/Stack/Client/DiscoveryClient.cs @@ -273,6 +273,12 @@ namespace Opc.Ua foreach (EndpointDescription discoveryEndPoint in endpoints) { Uri discoveryEndPointUri = Utils.ParseUri(discoveryEndPoint.EndpointUrl); + if (discoveryEndPointUri == null) + { + Utils.LogWarning("Discovery endpoint contains invalid Url: {0}", discoveryEndPoint.EndpointUrl); + continue; + } + if ((endpointUrl.Scheme == discoveryEndPointUri.Scheme) && (endpointUrl.Port == discoveryEndPointUri.Port)) {