From 167834487840161560f2ea0e33812655e95a5156 Mon Sep 17 00:00:00 2001 From: Biroj Nayak <49173255+birojnayak@users.noreply.github.com> Date: Fri, 2 Jun 2023 14:01:23 -0700 Subject: [PATCH 1/4] Unix domain socket binding on WCF Client --- System.ServiceModel.sln | 20 + .../Infrastructure/ConditionalWcfTest.cs | 5 + .../UDS/Binding.UDS.IntegrationTests.csproj | 19 + .../UDS/ServiceContract/EchoService.cs | 16 + .../UDS/ServiceContract/IEchoService.cs | 22 + .../Scenarios/Binding/UDS/ServiceHelper.cs | 121 +++ .../Scenarios/Binding/UDS/UDSBindingTests.cs | 300 ++++++ .../StreamSecurityUpgradeInitiatorBase.cs | 2 +- .../Channels/StreamUpgradeInitiator.cs | 2 +- .../src/System.ServiceModel.Primitives.csproj | 1 + .../src/Resources/strings.resx | 207 +++++ .../src/Resources/xlf/strings.cs.xlf | 152 +++ .../src/Resources/xlf/strings.de.xlf | 152 +++ .../src/Resources/xlf/strings.es.xlf | 152 +++ .../src/Resources/xlf/strings.fr.xlf | 152 +++ .../src/Resources/xlf/strings.it.xlf | 152 +++ .../src/Resources/xlf/strings.ja.xlf | 152 +++ .../src/Resources/xlf/strings.ko.xlf | 152 +++ .../src/Resources/xlf/strings.pl.xlf | 152 +++ .../src/Resources/xlf/strings.pt-BR.xlf | 152 +++ .../src/Resources/xlf/strings.ru.xlf | 152 +++ .../src/Resources/xlf/strings.tr.xlf | 152 +++ .../src/Resources/xlf/strings.zh-Hans.xlf | 152 +++ .../src/Resources/xlf/strings.zh-Hant.xlf | 152 +++ ...ystem.ServiceModel.UnixDomainSocket.csproj | 43 + .../Channels/ChannelBindingUtility.cs | 13 + .../Channels/SocketAwaitableEventArgs.cs | 128 +++ .../ServiceModel/Channels/SocketConnection.cs | 870 ++++++++++++++++++ .../Channels/SslProtocolsHelper.cs | 30 + .../Channels/TransportDefaults.cs | 38 + .../UnixDomainSocketChannelFactory.cs | 135 +++ .../UnixDomainSocketConnectionPoolSettings.cs | 127 +++ ...UnixDomainSocketTransportBindingElement.cs | 114 +++ .../UnixPosixIdentityBindingElement.cs | 69 ++ ...nixPosixIdentitySecurityUpgradeProvider.cs | 112 +++ .../Channels/UnsafeNativeMethods.cs | 24 + .../src/System/ServiceModel/TimeSpanHelper.cs | 30 + .../ServiceModel/UnixDomainSocketBinding.cs | 118 +++ .../UnixDomainSocketClientCredentialType.cs | 14 + ...xDomainSocketClientCredentialTypeHelper.cs | 18 + .../ServiceModel/UnixDomainSocketSecurity.cs | 67 ++ .../UnixDomainSocketSecurityMode.cs | 23 + .../UnixDomainSocketTransportSecurity.cs | 182 ++++ ...DomainSocketTransportBindingElementTest.cs | 25 + .../UnixDomainSocketBindingTest.cs | 106 +++ .../UnixDomainSocketSecurityTest.cs | 46 + .../UnixDomainSocketTransportSecurityTest.cs | 42 + ...ServiceModel.UnixDomainSocket.Tests.csproj | 15 + 48 files changed, 5078 insertions(+), 2 deletions(-) create mode 100644 src/System.Private.ServiceModel/tests/Scenarios/Binding/UDS/Binding.UDS.IntegrationTests.csproj create mode 100644 src/System.Private.ServiceModel/tests/Scenarios/Binding/UDS/ServiceContract/EchoService.cs create mode 100644 src/System.Private.ServiceModel/tests/Scenarios/Binding/UDS/ServiceContract/IEchoService.cs create mode 100644 src/System.Private.ServiceModel/tests/Scenarios/Binding/UDS/ServiceHelper.cs create mode 100644 src/System.Private.ServiceModel/tests/Scenarios/Binding/UDS/UDSBindingTests.cs create mode 100644 src/System.ServiceModel.UnixDomainSocket/src/Resources/strings.resx create mode 100644 src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.cs.xlf create mode 100644 src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.de.xlf create mode 100644 src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.es.xlf create mode 100644 src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.fr.xlf create mode 100644 src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.it.xlf create mode 100644 src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.ja.xlf create mode 100644 src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.ko.xlf create mode 100644 src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.pl.xlf create mode 100644 src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.pt-BR.xlf create mode 100644 src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.ru.xlf create mode 100644 src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.tr.xlf create mode 100644 src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.zh-Hans.xlf create mode 100644 src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.zh-Hant.xlf create mode 100644 src/System.ServiceModel.UnixDomainSocket/src/System.ServiceModel.UnixDomainSocket.csproj create mode 100644 src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/ChannelBindingUtility.cs create mode 100644 src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/SocketAwaitableEventArgs.cs create mode 100644 src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/SocketConnection.cs create mode 100644 src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/SslProtocolsHelper.cs create mode 100644 src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/TransportDefaults.cs create mode 100644 src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/UnixDomainSocketChannelFactory.cs create mode 100644 src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/UnixDomainSocketConnectionPoolSettings.cs create mode 100644 src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/UnixDomainSocketTransportBindingElement.cs create mode 100644 src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/UnixPosixIdentityBindingElement.cs create mode 100644 src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/UnixPosixIdentitySecurityUpgradeProvider.cs create mode 100644 src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/UnsafeNativeMethods.cs create mode 100644 src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/TimeSpanHelper.cs create mode 100644 src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/UnixDomainSocketBinding.cs create mode 100644 src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/UnixDomainSocketClientCredentialType.cs create mode 100644 src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/UnixDomainSocketClientCredentialTypeHelper.cs create mode 100644 src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/UnixDomainSocketSecurity.cs create mode 100644 src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/UnixDomainSocketSecurityMode.cs create mode 100644 src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/UnixDomainSocketTransportSecurity.cs create mode 100644 src/System.ServiceModel.UnixDomainSocket/tests/Channels/UnixDomainSocketTransportBindingElementTest.cs create mode 100644 src/System.ServiceModel.UnixDomainSocket/tests/ServiceModel/UnixDomainSocketBindingTest.cs create mode 100644 src/System.ServiceModel.UnixDomainSocket/tests/ServiceModel/UnixDomainSocketSecurityTest.cs create mode 100644 src/System.ServiceModel.UnixDomainSocket/tests/ServiceModel/UnixDomainSocketTransportSecurityTest.cs create mode 100644 src/System.ServiceModel.UnixDomainSocket/tests/System.ServiceModel.UnixDomainSocket.Tests.csproj diff --git a/System.ServiceModel.sln b/System.ServiceModel.sln index d950a43a275..64a9fe87fdd 100644 --- a/System.ServiceModel.sln +++ b/System.ServiceModel.sln @@ -17,6 +17,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.ServiceModel.NetTcp" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.ServiceModel.NetTcp.Tests", "src\System.ServiceModel.NetTcp\tests\System.ServiceModel.NetTcp.Tests.csproj", "{95C6CD71-6965-44E1-8F05-01F2F150B1E0}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.ServiceModel.UnixDomainSocket.Tests", "src\System.ServiceModel.UnixDomainSocket\tests\System.ServiceModel.UnixDomainSocket.Tests.csproj", "{58918456-A2B2-431F-BB95-BAAD2818BFC7}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Binding.Custom.IntegrationTests", "src\System.Private.ServiceModel\tests\Scenarios\Binding\Custom\Binding.Custom.IntegrationTests.csproj", "{D878F354-E120-476A-A90A-9E601A7E7580}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Binding.Http.IntegrationTests", "src\System.Private.ServiceModel\tests\Scenarios\Binding\Http\Binding.Http.IntegrationTests.csproj", "{2789D52D-9C17-4FCE-B81C-41B65C3FAFF9}" @@ -83,6 +85,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.ServiceModel.NetFram EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.ServiceModel.NetNamedPipe", "src\System.ServiceModel.NetNamedPipe\src\System.ServiceModel.NetNamedPipe.csproj", "{5ECB8887-D7EE-449F-9439-35D0BBBB1E07}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.ServiceModel.UnixDomainSocket", "src\System.ServiceModel.UnixDomainSocket\src\System.ServiceModel.UnixDomainSocket.csproj", "{1664DB18-8451-43C0-8A85-2DD9189C3897}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Binding.UDS.IntegrationTests", "src\System.Private.ServiceModel\tests\Scenarios\Binding\UDS\Binding.UDS.IntegrationTests.csproj", "{B7C7D4F1-DE4D-421B-9CE9-C7320A503D58}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -117,6 +123,10 @@ Global {95C6CD71-6965-44E1-8F05-01F2F150B1E0}.Debug|Any CPU.Build.0 = Debug|Any CPU {95C6CD71-6965-44E1-8F05-01F2F150B1E0}.Release|Any CPU.ActiveCfg = Release|Any CPU {95C6CD71-6965-44E1-8F05-01F2F150B1E0}.Release|Any CPU.Build.0 = Release|Any CPU + {58918456-A2B2-431F-BB95-BAAD2818BFC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {58918456-A2B2-431F-BB95-BAAD2818BFC7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {58918456-A2B2-431F-BB95-BAAD2818BFC7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {58918456-A2B2-431F-BB95-BAAD2818BFC7}.Release|Any CPU.Build.0 = Release|Any CPU {D878F354-E120-476A-A90A-9E601A7E7580}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D878F354-E120-476A-A90A-9E601A7E7580}.Debug|Any CPU.Build.0 = Debug|Any CPU {D878F354-E120-476A-A90A-9E601A7E7580}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -241,6 +251,14 @@ Global {5ECB8887-D7EE-449F-9439-35D0BBBB1E07}.Debug|Any CPU.Build.0 = Debug|Any CPU {5ECB8887-D7EE-449F-9439-35D0BBBB1E07}.Release|Any CPU.ActiveCfg = Release|Any CPU {5ECB8887-D7EE-449F-9439-35D0BBBB1E07}.Release|Any CPU.Build.0 = Release|Any CPU + {1664DB18-8451-43C0-8A85-2DD9189C3897}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1664DB18-8451-43C0-8A85-2DD9189C3897}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1664DB18-8451-43C0-8A85-2DD9189C3897}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1664DB18-8451-43C0-8A85-2DD9189C3897}.Release|Any CPU.Build.0 = Release|Any CPU + {B7C7D4F1-DE4D-421B-9CE9-C7320A503D58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B7C7D4F1-DE4D-421B-9CE9-C7320A503D58}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B7C7D4F1-DE4D-421B-9CE9-C7320A503D58}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B7C7D4F1-DE4D-421B-9CE9-C7320A503D58}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -249,6 +267,7 @@ Global {10C03A32-1B1F-4EF8-8041-92C34DAD221E} = {DFDC71CF-6E65-481D-99D7-C35ED7EF6D4E} {7805E0FD-3320-432B-91E1-D7BB7ABB781E} = {DFDC71CF-6E65-481D-99D7-C35ED7EF6D4E} {95C6CD71-6965-44E1-8F05-01F2F150B1E0} = {DFDC71CF-6E65-481D-99D7-C35ED7EF6D4E} + {58918456-A2B2-431F-BB95-BAAD2818BFC7} = {DFDC71CF-6E65-481D-99D7-C35ED7EF6D4E} {D878F354-E120-476A-A90A-9E601A7E7580} = {D6302510-AB10-4775-BCE9-98FA96FDEB76} {2789D52D-9C17-4FCE-B81C-41B65C3FAFF9} = {D6302510-AB10-4775-BCE9-98FA96FDEB76} {B38A2272-F260-4303-964C-ACDC9BADEB79} = {D6302510-AB10-4775-BCE9-98FA96FDEB76} @@ -276,6 +295,7 @@ Global {A3F8C509-AAE7-4391-9272-2221055CC17E} = {DFDC71CF-6E65-481D-99D7-C35ED7EF6D4E} {E8E40B62-E737-4768-82C2-039E90ED9A39} = {D6302510-AB10-4775-BCE9-98FA96FDEB76} {88918456-A2B2-431F-BB95-BAAD2818BFC7} = {DFDC71CF-6E65-481D-99D7-C35ED7EF6D4E} + {B7C7D4F1-DE4D-421B-9CE9-C7320A503D58} = {D6302510-AB10-4775-BCE9-98FA96FDEB76} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {E0638FAC-BA6B-4E18-BAE6-468C3191BE58} diff --git a/src/System.Private.ServiceModel/tests/Common/Infrastructure/ConditionalWcfTest.cs b/src/System.Private.ServiceModel/tests/Common/Infrastructure/ConditionalWcfTest.cs index db7ba6de4a2..e46570bdc5f 100644 --- a/src/System.Private.ServiceModel/tests/Common/Infrastructure/ConditionalWcfTest.cs +++ b/src/System.Private.ServiceModel/tests/Common/Infrastructure/ConditionalWcfTest.cs @@ -98,6 +98,11 @@ public static bool Is_Windows() ConditionalTestDetectors.IsWindows); } + public static bool IsNotWindows() + { + return !Is_Windows(); + } + // Returns 'true' if both the server and the client are domain-joined. public static bool Domain_Joined() { diff --git a/src/System.Private.ServiceModel/tests/Scenarios/Binding/UDS/Binding.UDS.IntegrationTests.csproj b/src/System.Private.ServiceModel/tests/Scenarios/Binding/UDS/Binding.UDS.IntegrationTests.csproj new file mode 100644 index 00000000000..492a0bc98df --- /dev/null +++ b/src/System.Private.ServiceModel/tests/Scenarios/Binding/UDS/Binding.UDS.IntegrationTests.csproj @@ -0,0 +1,19 @@ + + + $(ScenarioTestTargetFrameworks) + false + true + false + + + + + + + + + + + + + diff --git a/src/System.Private.ServiceModel/tests/Scenarios/Binding/UDS/ServiceContract/EchoService.cs b/src/System.Private.ServiceModel/tests/Scenarios/Binding/UDS/ServiceContract/EchoService.cs new file mode 100644 index 00000000000..276117cca5d --- /dev/null +++ b/src/System.Private.ServiceModel/tests/Scenarios/Binding/UDS/ServiceContract/EchoService.cs @@ -0,0 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using CoreWCF; + +namespace Binding.UDS.IntegrationTests.ServiceContract +{ + [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, InstanceContextMode = InstanceContextMode.Single)] + public class EchoService : IEchoService + { + public string Echo(string echo) + { + return echo; + } + } +} diff --git a/src/System.Private.ServiceModel/tests/Scenarios/Binding/UDS/ServiceContract/IEchoService.cs b/src/System.Private.ServiceModel/tests/Scenarios/Binding/UDS/ServiceContract/IEchoService.cs new file mode 100644 index 00000000000..580ff0911c7 --- /dev/null +++ b/src/System.Private.ServiceModel/tests/Scenarios/Binding/UDS/ServiceContract/IEchoService.cs @@ -0,0 +1,22 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.ServiceModel; + +namespace Binding.UDS.IntegrationTests.ServiceContract +{ + internal static partial class Constants + { + public const string NS = "http://tempuri.org/"; + public const string TESTSERVICE_NAME = nameof(IEchoService); + public const string OPERATION_BASE = NS + TESTSERVICE_NAME + "/"; + } + + [ServiceContract(Namespace = Constants.NS, Name = Constants.TESTSERVICE_NAME)] + public interface IEchoService + { + [OperationContract(Name = "Echo", Action = Constants.OPERATION_BASE + "Echo", + ReplyAction = Constants.OPERATION_BASE + "EchoResponse")] + string Echo(string echo); + } +} diff --git a/src/System.Private.ServiceModel/tests/Scenarios/Binding/UDS/ServiceHelper.cs b/src/System.Private.ServiceModel/tests/Scenarios/Binding/UDS/ServiceHelper.cs new file mode 100644 index 00000000000..ffc63e61a4b --- /dev/null +++ b/src/System.Private.ServiceModel/tests/Scenarios/Binding/UDS/ServiceHelper.cs @@ -0,0 +1,121 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Security.Cryptography.X509Certificates; +using System.Threading.Tasks; +using CoreWCF.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; + +namespace Binding.UDS.IntegrationTests +{ + internal class ServiceHelper + { + public static IHost CreateWebHostBuilder(string linuxSocketFilepath = "", [CallerMemberName] string callerMethodName = "") where TStartup : class + { + var startupType = typeof(TStartup); + var configureServicesMethod = startupType.GetMethod("ConfigureServices", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, new Type[] { typeof(IServiceCollection) }); + var configureMethod = startupType.GetMethod("Configure", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, new Type[] { typeof(IHost) }); + var startupInstance = Activator.CreateInstance(startupType); + var hostBuilder = Host.CreateDefaultBuilder(Array.Empty()); + hostBuilder.UseUnixDomainSocket(options => + { + options.Listen(new Uri("net.uds://" + linuxSocketFilepath)); + }); + if (configureServicesMethod != null) + { + var configureServiceAction = (Action)configureServicesMethod.CreateDelegate(typeof(Action), startupInstance); + hostBuilder.ConfigureServices(configureServiceAction); + } + + IHost host = hostBuilder.Build(); + if (configureMethod != null) + { + var configureAction = (Action)configureMethod.CreateDelegate(typeof(Action), startupInstance); + configureAction(host); + } + + return host; + } + + + //only for test, don't use in production code + public static X509Certificate2 GetServiceCertificate() + { + string AspNetHttpsOid = "1.3.6.1.4.1.311.84.1.1"; + X509Certificate2 foundCert = null; + using (var store = new X509Store(StoreName.My, StoreLocation.CurrentUser)) + { + // X509Store.Certificates creates a new instance of X509Certificate2Collection with + // each access to the property. The collection needs to be cleaned up correctly so + // keeping a single reference to fetched collection. + store.Open(OpenFlags.ReadOnly); + var certificates = store.Certificates; + foreach (var cert in certificates) + { + foreach (var extension in cert.Extensions) + { + if (AspNetHttpsOid.Equals(extension.Oid?.Value)) + { + // Always clone certificate instances when you don't own the creation + foundCert = new X509Certificate2(cert); + break; + } + } + + if (foundCert != null) + { + break; + } + } + // Cleanup + foreach (var cert in certificates) + { + cert.Dispose(); + } + } + + if (foundCert == null) + { + foundCert = ServiceUtilHelper.ClientCertificate; + } + + return foundCert; + } + + public static void CloseServiceModelObjects(params System.ServiceModel.ICommunicationObject[] objects) + { + foreach (System.ServiceModel.ICommunicationObject comObj in objects) + { + try + { + if (comObj == null) + { + continue; + } + // Only want to call Close if it is in the Opened state + if (comObj.State == System.ServiceModel.CommunicationState.Opened) + { + comObj.Close(); + } + // Anything not closed by this point should be aborted + if (comObj.State != System.ServiceModel.CommunicationState.Closed) + { + comObj.Abort(); + } + } + catch (TimeoutException) + { + comObj.Abort(); + } + catch (System.ServiceModel.CommunicationException) + { + comObj.Abort(); + } + } + } + } +} diff --git a/src/System.Private.ServiceModel/tests/Scenarios/Binding/UDS/UDSBindingTests.cs b/src/System.Private.ServiceModel/tests/Scenarios/Binding/UDS/UDSBindingTests.cs new file mode 100644 index 00000000000..21837176b7f --- /dev/null +++ b/src/System.Private.ServiceModel/tests/Scenarios/Binding/UDS/UDSBindingTests.cs @@ -0,0 +1,300 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.IO; +using System.Security.Cryptography.X509Certificates; +using System.ServiceModel; +using System.ServiceModel.Channels; +using System.ServiceModel.Description; +using System.Threading.Tasks; +using Binding.UDS.IntegrationTests; +using Binding.UDS.IntegrationTests.ServiceContract; +using CoreWCF.Configuration; +using Infrastructure.Common; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Xunit; + +public partial class Binding_UDSBindingTests : ConditionalWcfTest +{ + // Simple echo of a string using NetTcpBinding on both client and server with SecurityMode=None + [WcfFact] + [OuterLoop] + public static void SecurityModeNone_Echo_RoundTrips_String() + { + + string testString = new string('a', 3000); + IHost host = ServiceHelper.CreateWebHostBuilder(UDS.GetUDSFilePath()); + using (host) + { + System.ServiceModel.ChannelFactory factory = null; + IEchoService serviceProxy = null; + host.Start(); + try + { + System.ServiceModel.UnixDomainSocketBinding binding = new UnixDomainSocketBinding(UnixDomainSocketSecurityMode.None); + var uriBuilder = new UriBuilder() + { + Scheme = "net.uds", + Path = UDS.GetUDSFilePath() + }; + factory = new System.ServiceModel.ChannelFactory(binding, + new System.ServiceModel.EndpointAddress(uriBuilder.ToString())); + serviceProxy = factory.CreateChannel(); + ((IChannel)serviceProxy).Open(); + string result = serviceProxy.Echo(testString); + Assert.Equal(testString, result); + ((IChannel)serviceProxy).Close(); + factory.Close(); + } + finally + { + ServiceHelper.CloseServiceModelObjects((IChannel)serviceProxy, factory); + } + } + } + + [WcfFact] + [OuterLoop] + [Condition(nameof(Windows_Authentication_Available), + nameof(WindowsOrSelfHosted))] + public void WindowsAuth() + { + string testString = new string('a', 3000); + IHost host = ServiceHelper.CreateWebHostBuilder(UDS.GetUDSFilePath()); + using (host) + { + System.ServiceModel.ChannelFactory factory = null; + IEchoService channel = null; + host.Start(); + try + { + System.ServiceModel.UnixDomainSocketBinding binding = new UnixDomainSocketBinding(System.ServiceModel.UnixDomainSocketSecurityMode.Transport); + binding.Security.Transport.ClientCredentialType = System.ServiceModel.UnixDomainSocketClientCredentialType.Windows; + + var uriBuilder = new UriBuilder() + { + Scheme = "net.uds", + Path = UDS.GetUDSFilePath() + }; + factory = new System.ServiceModel.ChannelFactory(binding, + new System.ServiceModel.EndpointAddress(uriBuilder.ToString())); + channel = factory.CreateChannel(); + ((IChannel)channel).Open(); + string result = channel.Echo(testString); + Assert.Equal(testString, result); + ((IChannel)channel).Close(); + factory.Close(); + } + finally + { + ServiceHelper.CloseServiceModelObjects((IChannel)channel, factory); + } + } + } + + [WcfFact] + [Condition(nameof(SSL_Available))] + [OuterLoop] + private void BasicCertAsTransport() + { + string testString = new string('a', 3000); + IHost host = ServiceHelper.CreateWebHostBuilder(UDS.GetUDSFilePath()); + using (host) + { + host.Start(); + System.ServiceModel.UnixDomainSocketBinding binding = new System.ServiceModel.UnixDomainSocketBinding(System.ServiceModel.UnixDomainSocketSecurityMode.Transport); + binding.Security.Transport.ClientCredentialType = System.ServiceModel.UnixDomainSocketClientCredentialType.Certificate; + var uriBuilder = new UriBuilder() + { + Scheme = "net.uds", + Path = UDS.GetUDSFilePath() + }; + var cert = ServiceHelper.GetServiceCertificate(); + var identity = new X509CertificateEndpointIdentity(cert); + var factory = new System.ServiceModel.ChannelFactory(binding, + new System.ServiceModel.EndpointAddress(new Uri(uriBuilder.ToString()), identity)); + + factory.Credentials.ServiceCertificate.SslCertificateAuthentication = new System.ServiceModel.Security.X509ServiceCertificateAuthentication + { + CertificateValidationMode = System.ServiceModel.Security.X509CertificateValidationMode.None, + RevocationMode = X509RevocationMode.NoCheck + }; + + ClientCredentials clientCredentials = (ClientCredentials)factory.Endpoint.EndpointBehaviors[typeof(ClientCredentials)]; + clientCredentials.ClientCertificate.Certificate = cert; // this is a fake cert and we are not doing client cert validation + var channel = factory.CreateChannel(); + try + { + ((IChannel)channel).Open(); + string result = channel.Echo(testString); + Assert.Equal(testString, result); + ((IChannel)channel).Close(); + factory.Close(); + } + finally + { + ServiceHelper.CloseServiceModelObjects((IChannel)channel, factory); + } + } + } + + [WcfFact] + [OuterLoop] + [Condition(nameof(IsNotWindows))] + public void BasicIdentityOnlyAuthLinux() + { + string testString = new string('a', 3000); + IHost host = ServiceHelper.CreateWebHostBuilder(UDS.GetUDSFilePath()); + using (host) + { + System.ServiceModel.ChannelFactory factory = null; + IEchoService channel = null; + host.Start(); + try + { + System.ServiceModel.UnixDomainSocketBinding binding = new UnixDomainSocketBinding(UnixDomainSocketSecurityMode.TransportCredentialOnly); + binding.Security.Transport.ClientCredentialType = System.ServiceModel.UnixDomainSocketClientCredentialType.PosixIdentity; + + factory = new System.ServiceModel.ChannelFactory(binding, + new System.ServiceModel.EndpointAddress(new Uri("net.uds://" + UDS.GetUDSFilePath()))); + channel = factory.CreateChannel(); + ((IChannel)channel).Open(); + string result = channel.Echo(testString); + Assert.Equal(testString, result); + ((IChannel)channel).Close(); + factory.Close(); + } + finally + { + ServiceHelper.CloseServiceModelObjects((IChannel)channel, factory); + } + } + } + + public class UDS + { + public static string GetUDSFilePath() + { + return Path.Combine(Path.GetTempPath(), "unix1.txt"); + } + } + + public class StartUpForUDS : UDS + { + public void ConfigureServices(IServiceCollection services) + { + services.AddServiceModelServices(); + } + + public void Configure(IHost host) + { + CoreWCF.UnixDomainSocketBinding serverBinding = new CoreWCF.UnixDomainSocketBinding(CoreWCF.SecurityMode.None); + host.UseServiceModel(builder => + { + builder.AddService(); + builder.AddServiceEndpoint(serverBinding, "net.uds://" + GetUDSFilePath()); + }); + } + } + + public class StartupForWindowsAuth : UDS + { + public void ConfigureServices(IServiceCollection services) + { + services.AddServiceModelServices(); + } + + public void Configure(IHost host) + { + host.UseServiceModel(builder => + { + builder.AddService(); + var udsBinding = new CoreWCF.UnixDomainSocketBinding + { + Security = new CoreWCF.UnixDomainSocketSecurity + { + Mode = CoreWCF.SecurityMode.Transport, + Transport = new CoreWCF.UnixDomainSocketTransportSecurity + { + ClientCredentialType = CoreWCF.UnixDomainSocketClientCredentialType.Windows, + }, + }, + }; + + builder.AddServiceEndpoint(udsBinding, "net.uds://" + GetUDSFilePath()); + }); + } + } + + public class StartupForUnixDomainSocketTransportCertificate : UDS + { + public void ConfigureServices(IServiceCollection services) + { + services.AddServiceModelServices(); + } + + public void Configure(IHost host) + { + host.UseServiceModel(builder => + { + builder.AddService(); + var udsBinding = new CoreWCF.UnixDomainSocketBinding + { + Security = new CoreWCF.UnixDomainSocketSecurity + { + Mode = CoreWCF.SecurityMode.Transport, + Transport = new CoreWCF.UnixDomainSocketTransportSecurity + { + ClientCredentialType = CoreWCF.UnixDomainSocketClientCredentialType.Certificate, + }, + }, + }; + + builder.AddServiceEndpoint(udsBinding, "net.uds://" + GetUDSFilePath()); + Action serviceHost = host => ChangeHostBehavior(host); + builder.ConfigureServiceHostBase(serviceHost); + }); + } + + public void ChangeHostBehavior(CoreWCF.ServiceHostBase host) + { + var srvCredentials = host.Credentials; + //provide the certificate, here we are getting the default asp.net core default certificate, not recommended for prod workload. + srvCredentials.ServiceCertificate.Certificate = ServiceHelper.GetServiceCertificate(); + srvCredentials.ClientCertificate.Authentication.CertificateValidationMode = CoreWCF.Security.X509CertificateValidationMode.None; + } + } + + public class StartupForUnixDomainSocketTransportIdentity : UDS + { + public void ConfigureServices(IServiceCollection services) + { + services.AddServiceModelServices(); + } + + public void Configure(IHost host) + { + host.UseServiceModel(builder => + { + builder.AddService(); + var udsBinding = new CoreWCF.UnixDomainSocketBinding + { + Security = new CoreWCF.UnixDomainSocketSecurity + { + Mode = CoreWCF.SecurityMode.Transport, + Transport = new CoreWCF.UnixDomainSocketTransportSecurity + { + ClientCredentialType = CoreWCF.UnixDomainSocketClientCredentialType.IdentityOnly, + }, + }, + }; + + builder.AddServiceEndpoint(udsBinding, "net.uds://" + GetUDSFilePath()); + }); + } + } +} diff --git a/src/System.ServiceModel.NetFramingBase/src/System/ServiceModel/Channels/StreamSecurityUpgradeInitiatorBase.cs b/src/System.ServiceModel.NetFramingBase/src/System/ServiceModel/Channels/StreamSecurityUpgradeInitiatorBase.cs index 774b74d375b..11995dc3a5b 100644 --- a/src/System.ServiceModel.NetFramingBase/src/System/ServiceModel/Channels/StreamSecurityUpgradeInitiatorBase.cs +++ b/src/System.ServiceModel.NetFramingBase/src/System/ServiceModel/Channels/StreamSecurityUpgradeInitiatorBase.cs @@ -42,7 +42,7 @@ public override SecurityMessageProperty GetRemoteSecurity() return _remoteSecurity; } - internal override async Task InitiateUpgradeAsync(Stream stream) + public override async Task InitiateUpgradeAsync(Stream stream) { if (stream == null) { diff --git a/src/System.ServiceModel.NetFramingBase/src/System/ServiceModel/Channels/StreamUpgradeInitiator.cs b/src/System.ServiceModel.NetFramingBase/src/System/ServiceModel/Channels/StreamUpgradeInitiator.cs index 860dce73365..d92e74a06e9 100644 --- a/src/System.ServiceModel.NetFramingBase/src/System/ServiceModel/Channels/StreamUpgradeInitiator.cs +++ b/src/System.ServiceModel.NetFramingBase/src/System/ServiceModel/Channels/StreamUpgradeInitiator.cs @@ -10,7 +10,7 @@ public abstract class StreamUpgradeInitiator { protected StreamUpgradeInitiator() { } public abstract string GetNextUpgrade(); - internal abstract Task InitiateUpgradeAsync(Stream stream); + public abstract Task InitiateUpgradeAsync(Stream stream); internal virtual ValueTask OpenAsync(TimeSpan timeout) => default; internal virtual ValueTask CloseAsync(TimeSpan timeout) => default; } diff --git a/src/System.ServiceModel.Primitives/src/System.ServiceModel.Primitives.csproj b/src/System.ServiceModel.Primitives/src/System.ServiceModel.Primitives.csproj index ea56407ec80..2a13dae411f 100644 --- a/src/System.ServiceModel.Primitives/src/System.ServiceModel.Primitives.csproj +++ b/src/System.ServiceModel.Primitives/src/System.ServiceModel.Primitives.csproj @@ -19,6 +19,7 @@ + diff --git a/src/System.ServiceModel.UnixDomainSocket/src/Resources/strings.resx b/src/System.ServiceModel.UnixDomainSocket/src/Resources/strings.resx new file mode 100644 index 00000000000..99f43d70532 --- /dev/null +++ b/src/System.ServiceModel.UnixDomainSocket/src/Resources/strings.resx @@ -0,0 +1,207 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ClientCredentialType.None is not valid for the TransportWithMessageCredential security mode. Specify a message credential type or use a different security mode. + + + Extended protection is not supported on this platform. Please install the appropriate patch or change the ExtendedProtectionPolicy on the Binding or BindingElement to a value with a PolicyEnforcement value of "Never" or "WhenSupported". + + + The protection level '{0}' was specified, yet SSL transport security only supports EncryptAndSign. + + + Timeout must be greater than or equal to TimeSpan.Zero. To disable timeout, specify TimeSpan.MaxValue. + + + Timeouts larger than Int32.MaxValue TotalMilliseconds (approximately 24 days) cannot be honored. To disable timeout, specify TimeSpan.MaxValue. + + + The value of this argument must be non-negative. + + + The specified channel type {0} is not supported by this channel manager. + + + Could not connect to {0}. UDS error code {1}: {2}. + + + Could not connect to {0}. The connection attempt lasted for a time span of {3}. UDS error code {1}: {2}. + + + A UDS error ({0}: {1}) occurred while transmitting data. + + + The socket connection was aborted by your local machine. This could be caused by a channel Abort(), or a transmission error from another thread using this socket. + + + The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '{0}'. + + + The socket transfer timed out after {0}. You have exceeded the timeout set on your binding. The time allotted to this operation may have been a portion of a longer timeout. + + + The socket connection has been disposed. + + + Insufficient winsock resources available to complete socket connection initiation. + + + Insufficient memory avaliable to complete the operation. + + + Cannot resolve the host name of URI "{0}" using DNS. + + + No DNS entries exist for host {0}. + + + Connecting to via {0} timed out after {1}. Connection attempts were made to {2} of {3} available addresses ({4}). Check the RemoteAddress of your channel and verify that the DNS records for this endpoint correspond to valid IP Addresses. The time allotted to this operation may have been a portion of a longer timeout. + + + No IPEndpoints were found for host {0}. + + + The socket was aborted because an asynchronous receive from the socket did not complete within the allotted timeout of {0}. The time allotted to this operation may have been a portion of a longer timeout. + + + The socket connection was aborted because an asynchronous send to the socket did not complete within the allotted timeout of {0}. The time allotted to this operation may have been a portion of a longer timeout. + + + The value of this argument must be positive. + + + The remote endpoint of the socket ({0}) did not respond to a close request within the allotted timeout ({1}). It is likely that the remote endpoint is not calling Close after receiving the EOF signal (null) from Receive. The time allotted to this operation may have been a portion of a longer timeout. + + + A graceful close was attempted on the socket, but the other side ({0}) is still sending data. + + + Process action '{0}'. + + + Server '{0}' sent back a fault indicating it is too busy to process the request. Please retry later. Please see the inner exception for fault details. + + + Server '{0}' sent back a fault indicating it is in the process of shutting down. Please see the inner exception for fault details. + + + Transfer mode {0} is not supported by {1}. + + diff --git a/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.cs.xlf b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.cs.xlf new file mode 100644 index 00000000000..7676d7c7d28 --- /dev/null +++ b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.cs.xlf @@ -0,0 +1,152 @@ + + + + + + Process action '{0}'. + Zpracujte akci {0}. + + + + The specified channel type {0} is not supported by this channel manager. + Určený typ kanálu {0} není tímto správcem kanálů podporován. + + + + ClientCredentialType.None is not valid for the TransportWithMessageCredential security mode. Specify a message credential type or use a different security mode. + Třída ClientCredentialType.None není pro režim zabezpečení TransportWithMessageCredential platný. Určete typ přihlašovacích údajů zprávy nebo použijte jiný režim zabezpečení. + + + + No DNS entries exist for host {0}. + Neexistují položky DNS hostitele {0}. + + + + Extended protection is not supported on this platform. Please install the appropriate patch or change the ExtendedProtectionPolicy on the Binding or BindingElement to a value with a PolicyEnforcement value of "Never" or "WhenSupported". + Rozšířená ochrana není na této platformě podporována. Instalujte odpovídající opravu nebo změňte vlastnost ExtendedProtectionPolicy objektu Binding nebo BindingElement na hodnotu s nastavením PolicyEnforcement Never nebo WhenSupported. + + + + Insufficient memory avaliable to complete the operation. + K dokončení operace není dostatek paměti. + + + + No IPEndpoints were found for host {0}. + Pro hostitele {0} nebyly nalezeny žádné třídy IPEndpoints. + + + + Timeout must be greater than or equal to TimeSpan.Zero. To disable timeout, specify TimeSpan.MaxValue. + Časový limit musí být větší než nula nebo se rovnat hodnotě TimeSpan.Zero. Pokud chcete časový limit zakázat, zadejte hodnotu TimeSpan.MaxValue. + + + + Timeouts larger than Int32.MaxValue TotalMilliseconds (approximately 24 days) cannot be honored. To disable timeout, specify TimeSpan.MaxValue. + Časový limit větší než hodnota Int32.MaxValue TotalMilliseconds (přibližně 24 dní) nelze akceptovat. Pokud chcete časový limit zakázat, zadejte hodnotu TimeSpan.MaxValue. + + + + Server '{0}' sent back a fault indicating it is in the process of shutting down. Please see the inner exception for fault details. + Server {0} odeslal zpět chybu, která udává, že probíhá jeho vypínání. Podrobné informace o chybě naleznete v popisu vnitřní výjimky. + + + + Server '{0}' sent back a fault indicating it is too busy to process the request. Please retry later. Please see the inner exception for fault details. + Server {0} odeslal zpět chybu, která udává, že je příliš zaneprázdněn a nemůže zpracovat požadavek. Podrobné informace o chybě naleznete v popisu vnitřní výjimky. + + + + The socket was aborted because an asynchronous receive from the socket did not complete within the allotted timeout of {0}. The time allotted to this operation may have been a portion of a longer timeout. + Soket byl přerušen, protože se asynchronní příjem ze soketu nedokončil v rámci přiděleného časového limitu {0}. Čas přidělený této operaci byl pravděpodobně částí delšího časového limitu. + + + + The socket connection was aborted because an asynchronous send to the socket did not complete within the allotted timeout of {0}. The time allotted to this operation may have been a portion of a longer timeout. + Připojení soketu bylo přerušeno, protože se asynchronní odeslání do soketu nedokončilo v rámci přiděleného časového limitu {0}. Čas přidělený této operaci byl pravděpodobně částí delšího časového limitu. + + + + A graceful close was attempted on the socket, but the other side ({0}) is still sending data. + U soketu byl proveden pokus o řádné zavření, ale druhá strana ({0}) stále odesílá data. + + + + The remote endpoint of the socket ({0}) did not respond to a close request within the allotted timeout ({1}). It is likely that the remote endpoint is not calling Close after receiving the EOF signal (null) from Receive. The time allotted to this operation may have been a portion of a longer timeout. + Vzdálený koncový bod soketu ({0}) neodpověděl na požadavek zavření v rámci přiděleného časového limitu ({1}). Je pravděpodobné, že vzdálený koncový bod nevolá zavření po přijetí signálu EOF (null) z parametru Receive. Čas přidělený této operaci byl pravděpodobně částí delšího časového limitu. + + + + The socket connection has been disposed. + Připojení soketu bylo zrušeno. + + + + Transfer mode {0} is not supported by {1}. + {1} nepodporuje režim přenosu {0}. + + + + Could not connect to {0}. UDS error code {1}: {2}. + Could not connect to {0}. UDS error code {1}: {2}. + + + + Could not connect to {0}. The connection attempt lasted for a time span of {3}. UDS error code {1}: {2}. + Could not connect to {0}. The connection attempt lasted for a time span of {3}. UDS error code {1}: {2}. + + + + Insufficient winsock resources available to complete socket connection initiation. + Insufficient winsock resources available to complete socket connection initiation. + + + + Connecting to via {0} timed out after {1}. Connection attempts were made to {2} of {3} available addresses ({4}). Check the RemoteAddress of your channel and verify that the DNS records for this endpoint correspond to valid IP Addresses. The time allotted to this operation may have been a portion of a longer timeout. + Connecting to via {0} timed out after {1}. Connection attempts were made to {2} of {3} available addresses ({4}). Check the RemoteAddress of your channel and verify that the DNS records for this endpoint correspond to valid IP Addresses. The time allotted to this operation may have been a portion of a longer timeout. + + + + The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '{0}'. + The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '{0}'. + + + + The socket transfer timed out after {0}. You have exceeded the timeout set on your binding. The time allotted to this operation may have been a portion of a longer timeout. + The socket transfer timed out after {0}. You have exceeded the timeout set on your binding. The time allotted to this operation may have been a portion of a longer timeout. + + + + The socket connection was aborted by your local machine. This could be caused by a channel Abort(), or a transmission error from another thread using this socket. + The socket connection was aborted by your local machine. This could be caused by a channel Abort(), or a transmission error from another thread using this socket. + + + + A UDS error ({0}: {1}) occurred while transmitting data. + A UDS error ({0}: {1}) occurred while transmitting data. + + + + Cannot resolve the host name of URI "{0}" using DNS. + Nelze vyřešit název hostitele identifikátoru URI {0} pomocí služby DNS. + + + + The protection level '{0}' was specified, yet SSL transport security only supports EncryptAndSign. + Byla zadána úroveň zabezpečení {0}, ale zabezpečení přenosu SSL podporuje pouze EncryptAndSign. + + + + The value of this argument must be non-negative. + Hodnota tohoto argumentu nesmí být záporná. + + + + The value of this argument must be positive. + Hodnota tohoto argumentu musí být kladná. + + + + + \ No newline at end of file diff --git a/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.de.xlf b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.de.xlf new file mode 100644 index 00000000000..0fb81e561ef --- /dev/null +++ b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.de.xlf @@ -0,0 +1,152 @@ + + + + + + Process action '{0}'. + Aktion "{0}" verarbeiten. + + + + The specified channel type {0} is not supported by this channel manager. + Der angegebene Kanaltyp {0} wird von diesem Kanal-Manager nicht unterstützt. + + + + ClientCredentialType.None is not valid for the TransportWithMessageCredential security mode. Specify a message credential type or use a different security mode. + ClientCredentialType.None ist für den TransportWithMessageCredential-Sicherheitsmodus ungültig. Geben Sie einen Anmeldeinformationstyp für Nachrichten an, oder verwenden Sie einen anderen Sicherheitsmodus. + + + + No DNS entries exist for host {0}. + Für den Host {0} sind keine DNS-Einträge vorhanden. + + + + Extended protection is not supported on this platform. Please install the appropriate patch or change the ExtendedProtectionPolicy on the Binding or BindingElement to a value with a PolicyEnforcement value of "Never" or "WhenSupported". + Der erweiterte Schutz wird auf dieser Plattform nicht unterstützt. Installieren Sie einen geeigneten Patch, oder ändern Sie ExtendedProtectionPolicy der Bindung oder das BindingElement in einen Wert mit dem PolicyEnforcement-Wert "Never" oder "WhenSupported". + + + + Insufficient memory avaliable to complete the operation. + Es ist nicht ausreichend Arbeitsspeicher verfügbar, um den Vorgang abzuschließen. + + + + No IPEndpoints were found for host {0}. + Es wurden keine IPEndpoints für den Host {0} gefunden. + + + + Timeout must be greater than or equal to TimeSpan.Zero. To disable timeout, specify TimeSpan.MaxValue. + Das Zeitlimit muss größer oder gleich TimeSpan.Zero sein. Geben Sie den TimeSpan.MaxValue an, um das Zeitlimit zu deaktivieren. + + + + Timeouts larger than Int32.MaxValue TotalMilliseconds (approximately 24 days) cannot be honored. To disable timeout, specify TimeSpan.MaxValue. + Zeitlimits, die größer als Int32.MaxValue TotalMilliseconds (ca. 24 Tage) sind, können nicht akzeptiert werden. Geben Sie den TimeSpan.MaxValue an, um das Zeitlimit zu deaktivieren. + + + + Server '{0}' sent back a fault indicating it is in the process of shutting down. Please see the inner exception for fault details. + Der Server "{0}" hat einen Fehler zurückgesendet, der darauf hinweist, dass der Server gerade heruntergefahren wird. Detaillierte Fehlerinformationen finden Sie in der inneren Ausnahme. + + + + Server '{0}' sent back a fault indicating it is too busy to process the request. Please retry later. Please see the inner exception for fault details. + Der Server "{0}" hat einen Fehler zurückgesendet, der darauf hinweist, dass er zu ausgelastet ist, um die Anforderung zu verarbeiten. Versuchen Sie es später noch mal. Detaillierte Fehlerinformationen finden Sie in der inneren Ausnahme. + + + + The socket was aborted because an asynchronous receive from the socket did not complete within the allotted timeout of {0}. The time allotted to this operation may have been a portion of a longer timeout. + Der Socket wurde abgebrochen, da ein asynchroner Empfangsvorgang vom Socket nicht innerhalb des zugewiesenen Zeitlimits von {0} abgeschlossen wurde. Der für diesen Vorgang zugewiesene Zeitraum war möglicherweise ein Teil eines längeren Zeitlimits. + + + + The socket connection was aborted because an asynchronous send to the socket did not complete within the allotted timeout of {0}. The time allotted to this operation may have been a portion of a longer timeout. + Die Socketverbindung wurde abgebrochen, da ein asynchroner Sendevorgang an den Socket nicht innerhalb des zugewiesenen Zeitlimits von {0} abgeschlossen wurde. Der für diesen Vorgang zugewiesene Zeitraum war möglicherweise ein Teil eines längeren Zeitlimits. + + + + A graceful close was attempted on the socket, but the other side ({0}) is still sending data. + Es wurde versucht, das Socket ordnungsgemäß zu schließen, aber die andere Seite ({0}) sendet weiterhin Daten. + + + + The remote endpoint of the socket ({0}) did not respond to a close request within the allotted timeout ({1}). It is likely that the remote endpoint is not calling Close after receiving the EOF signal (null) from Receive. The time allotted to this operation may have been a portion of a longer timeout. + Der Remoteendpunkt des Sockets ({0}) hat auf eine Anforderung zum Schließen nicht innerhalb des zugewiesenen Zeitlimits ({1}) geantwortet. Vermutlich ruft der Remoteendpunkt nach dem Empfang des EOF-Signals (NULL) von "Receive" nicht die Close-Methode auf. Der für diesen Vorgang zugewiesene Zeitraum war möglicherweise ein Teil eines längeren Zeitlimits. + + + + The socket connection has been disposed. + Die Socketverbindung wurde verworfen. + + + + Transfer mode {0} is not supported by {1}. + Der Übertragungsmodus {0} wird von {1} nicht unterstützt. + + + + Could not connect to {0}. UDS error code {1}: {2}. + Could not connect to {0}. UDS error code {1}: {2}. + + + + Could not connect to {0}. The connection attempt lasted for a time span of {3}. UDS error code {1}: {2}. + Could not connect to {0}. The connection attempt lasted for a time span of {3}. UDS error code {1}: {2}. + + + + Insufficient winsock resources available to complete socket connection initiation. + Insufficient winsock resources available to complete socket connection initiation. + + + + Connecting to via {0} timed out after {1}. Connection attempts were made to {2} of {3} available addresses ({4}). Check the RemoteAddress of your channel and verify that the DNS records for this endpoint correspond to valid IP Addresses. The time allotted to this operation may have been a portion of a longer timeout. + Connecting to via {0} timed out after {1}. Connection attempts were made to {2} of {3} available addresses ({4}). Check the RemoteAddress of your channel and verify that the DNS records for this endpoint correspond to valid IP Addresses. The time allotted to this operation may have been a portion of a longer timeout. + + + + The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '{0}'. + The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '{0}'. + + + + The socket transfer timed out after {0}. You have exceeded the timeout set on your binding. The time allotted to this operation may have been a portion of a longer timeout. + The socket transfer timed out after {0}. You have exceeded the timeout set on your binding. The time allotted to this operation may have been a portion of a longer timeout. + + + + The socket connection was aborted by your local machine. This could be caused by a channel Abort(), or a transmission error from another thread using this socket. + The socket connection was aborted by your local machine. This could be caused by a channel Abort(), or a transmission error from another thread using this socket. + + + + A UDS error ({0}: {1}) occurred while transmitting data. + A UDS error ({0}: {1}) occurred while transmitting data. + + + + Cannot resolve the host name of URI "{0}" using DNS. + Der Hostname von URI "{0}" kann nicht mithilfe von DNS aufgelöst werden. + + + + The protection level '{0}' was specified, yet SSL transport security only supports EncryptAndSign. + Die Schutzebene "{0}" war angegeben, die SSL-Transportsicherheit unterstützt jedoch nur EncryptAndSign. + + + + The value of this argument must be non-negative. + Der Wert dieses Arguments darf keine negative Zahl sein. + + + + The value of this argument must be positive. + Der Wert dieses Arguments muss positiv sein. + + + + + \ No newline at end of file diff --git a/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.es.xlf b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.es.xlf new file mode 100644 index 00000000000..d82f259155b --- /dev/null +++ b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.es.xlf @@ -0,0 +1,152 @@ + + + + + + Process action '{0}'. + Procese la acción "{0}". + + + + The specified channel type {0} is not supported by this channel manager. + Este administrador de canales no admite el tipo de canal especificado {0}. + + + + ClientCredentialType.None is not valid for the TransportWithMessageCredential security mode. Specify a message credential type or use a different security mode. + ClientCredentialType.None no es válido para el modo de seguridad TransportWithMessageCredential. Especifique un tipo de credencial de mensaje o use otro modo de seguridad. + + + + No DNS entries exist for host {0}. + No existen entradas DNS para el host {0}. + + + + Extended protection is not supported on this platform. Please install the appropriate patch or change the ExtendedProtectionPolicy on the Binding or BindingElement to a value with a PolicyEnforcement value of "Never" or "WhenSupported". + La protección extendida no se admite en esta plataforma. Instale la revisión correspondiente o cambie ExtendedProtectionPolicy en Binding o BindingElement por un valor de PolicyEnforcement "Never" o "WhenSupported". + + + + Insufficient memory avaliable to complete the operation. + No hay suficiente memoria disponible para completar la operación. + + + + No IPEndpoints were found for host {0}. + No se encontraron elementos IPEndpoints para el host {0}. + + + + Timeout must be greater than or equal to TimeSpan.Zero. To disable timeout, specify TimeSpan.MaxValue. + El tiempo de espera debe ser mayor o igual que TimeSpan.Zero. Para deshabilitar el tiempo de espera, especifique TimeSpan.MaxValue. + + + + Timeouts larger than Int32.MaxValue TotalMilliseconds (approximately 24 days) cannot be honored. To disable timeout, specify TimeSpan.MaxValue. + No se pueden aceptar valores de tiempo de espera mayores que Int32.MaxValue TotalMilliseconds (aproximadamente 24 días). Para deshabilitar el tiempo de espera, especifique TimeSpan.MaxValue. + + + + Server '{0}' sent back a fault indicating it is in the process of shutting down. Please see the inner exception for fault details. + El servidor '{0}' devolvió un error que indica que está en proceso de cerrarse. Consulte la excepción interna para obtener más información del error. + + + + Server '{0}' sent back a fault indicating it is too busy to process the request. Please retry later. Please see the inner exception for fault details. + El servidor "{0}" devolvió un error que indica que está demasiado ocupado para procesar la solicitud. Inténtelo de nuevo más adelante. Consulte la excepción interna para obtener más información del error. + + + + The socket was aborted because an asynchronous receive from the socket did not complete within the allotted timeout of {0}. The time allotted to this operation may have been a portion of a longer timeout. + Se anuló el socket porque una recepción asincrónica del socket no se completó en el tiempo de espera asignado de {0}. El tiempo asignado a esta operación puede haber sido una parte de un tiempo de espera mayor. + + + + The socket connection was aborted because an asynchronous send to the socket did not complete within the allotted timeout of {0}. The time allotted to this operation may have been a portion of a longer timeout. + Se anuló la conexión de socket porque un envío asincrónico al socket no se completó en el tiempo de espera asignado de {0}. El tiempo asignado a esta operación puede haber sido una parte de un tiempo de espera mayor. + + + + A graceful close was attempted on the socket, but the other side ({0}) is still sending data. + Se intentó cerrar correctamente el socket, pero el otro lado ({0}) sigue enviando datos. + + + + The remote endpoint of the socket ({0}) did not respond to a close request within the allotted timeout ({1}). It is likely that the remote endpoint is not calling Close after receiving the EOF signal (null) from Receive. The time allotted to this operation may have been a portion of a longer timeout. + El punto de conexión remoto del socket ({0}) no respondió a una solicitud de cierre en el tiempo de espera asignado ({1}). Es probable que el punto de conexión remoto no llame a Close después de recibir la señal EOF (valor nulo) de Receive. El tiempo asignado a esta operación puede haber sido una parte de un tiempo de espera mayor. + + + + The socket connection has been disposed. + Se desechó la conexión de socket. + + + + Transfer mode {0} is not supported by {1}. + El modo de transferencia {0} no se admite en {1}. + + + + Could not connect to {0}. UDS error code {1}: {2}. + Could not connect to {0}. UDS error code {1}: {2}. + + + + Could not connect to {0}. The connection attempt lasted for a time span of {3}. UDS error code {1}: {2}. + Could not connect to {0}. The connection attempt lasted for a time span of {3}. UDS error code {1}: {2}. + + + + Insufficient winsock resources available to complete socket connection initiation. + Insufficient winsock resources available to complete socket connection initiation. + + + + Connecting to via {0} timed out after {1}. Connection attempts were made to {2} of {3} available addresses ({4}). Check the RemoteAddress of your channel and verify that the DNS records for this endpoint correspond to valid IP Addresses. The time allotted to this operation may have been a portion of a longer timeout. + Connecting to via {0} timed out after {1}. Connection attempts were made to {2} of {3} available addresses ({4}). Check the RemoteAddress of your channel and verify that the DNS records for this endpoint correspond to valid IP Addresses. The time allotted to this operation may have been a portion of a longer timeout. + + + + The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '{0}'. + The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '{0}'. + + + + The socket transfer timed out after {0}. You have exceeded the timeout set on your binding. The time allotted to this operation may have been a portion of a longer timeout. + The socket transfer timed out after {0}. You have exceeded the timeout set on your binding. The time allotted to this operation may have been a portion of a longer timeout. + + + + The socket connection was aborted by your local machine. This could be caused by a channel Abort(), or a transmission error from another thread using this socket. + The socket connection was aborted by your local machine. This could be caused by a channel Abort(), or a transmission error from another thread using this socket. + + + + A UDS error ({0}: {1}) occurred while transmitting data. + A UDS error ({0}: {1}) occurred while transmitting data. + + + + Cannot resolve the host name of URI "{0}" using DNS. + No se puede resolver el nombre de host del URI "{0}" con DNS. + + + + The protection level '{0}' was specified, yet SSL transport security only supports EncryptAndSign. + Se especificó el nivel de protección "{0}", pero la seguridad de transporte SSL solo admite EncryptAndSign. + + + + The value of this argument must be non-negative. + El valor de este argumento no puede ser negativo. + + + + The value of this argument must be positive. + El valor de este argumento debe ser positivo. + + + + + \ No newline at end of file diff --git a/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.fr.xlf b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.fr.xlf new file mode 100644 index 00000000000..779a2b59b9c --- /dev/null +++ b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.fr.xlf @@ -0,0 +1,152 @@ + + + + + + Process action '{0}'. + Traiter l'action '{0}'. + + + + The specified channel type {0} is not supported by this channel manager. + Le type de canal {0} spécifié n'est pas pris en charge par ce gestionnaire de canaux. + + + + ClientCredentialType.None is not valid for the TransportWithMessageCredential security mode. Specify a message credential type or use a different security mode. + ClientCredentialType.None est non valide pour le mode de sécurité TransportWithMessageCredential. Indiquez un type pour les informations d'identification de message ou utilisez un autre mode de sécurité. + + + + No DNS entries exist for host {0}. + Aucune entrée DNS n'existe pour l'hôte {0}. + + + + Extended protection is not supported on this platform. Please install the appropriate patch or change the ExtendedProtectionPolicy on the Binding or BindingElement to a value with a PolicyEnforcement value of "Never" or "WhenSupported". + La protection étendue n'est pas prise en charge sur cette plateforme. Installez le correctif approprié ou remplacez le ExtendedProtectionPolicy sur Binding ou BindingElement en par une valeur PolicyEnforcement de "Never" ou "WhenSupported". + + + + Insufficient memory avaliable to complete the operation. + Mémoire disponible insuffisante pour effectuer l'opération. + + + + No IPEndpoints were found for host {0}. + IPEndpoints introuvables pour l'hôte {0}. + + + + Timeout must be greater than or equal to TimeSpan.Zero. To disable timeout, specify TimeSpan.MaxValue. + Le délai d'expiration doit être supérieur ou égal à TimeSpan.Zero. Pour désactiver le délai d'expiration, spécifiez TimeSpan.MaxValue. + + + + Timeouts larger than Int32.MaxValue TotalMilliseconds (approximately 24 days) cannot be honored. To disable timeout, specify TimeSpan.MaxValue. + Les délais d'expiration supérieurs à Int32.MaxValue TotalMilliseconds (soit environ 24 jours) ne peuvent pas être appliqués. Pour désactiver le délai d'expiration, spécifiez TimeSpan.MaxValue. + + + + Server '{0}' sent back a fault indicating it is in the process of shutting down. Please see the inner exception for fault details. + Le serveur '{0}' a renvoyé une erreur indiquant qu'il est en cours d'arrêt. Consultez l'exception interne pour obtenir des détails sur l'erreur. + + + + Server '{0}' sent back a fault indicating it is too busy to process the request. Please retry later. Please see the inner exception for fault details. + Le serveur '{0}' a envoyé une erreur indiquant qu'il est trop occupé pour traiter la requête. Réessayez plus tard. Consultez l'exception interne pour obtenir des détails sur l'erreur. + + + + The socket was aborted because an asynchronous receive from the socket did not complete within the allotted timeout of {0}. The time allotted to this operation may have been a portion of a longer timeout. + Le socket a été abandonné, car une réception asynchrone du socket ne s'est pas effectuée dans le délai imparti de {0}. Le temps alloué à cette opération fait peut-être partie d'un délai d'expiration plus long. + + + + The socket connection was aborted because an asynchronous send to the socket did not complete within the allotted timeout of {0}. The time allotted to this operation may have been a portion of a longer timeout. + La connexion au socket a été abandonnée, car un envoi asynchrone au socket ne s'est pas effectué dans le délai imparti de {0}. Le temps alloué à cette opération fait peut-être partie d'un délai d'expiration plus long. + + + + A graceful close was attempted on the socket, but the other side ({0}) is still sending data. + Une fermeture normale a été tentée sur le socket, mais l'autre côté ({0}) envoie toujours des données. + + + + The remote endpoint of the socket ({0}) did not respond to a close request within the allotted timeout ({1}). It is likely that the remote endpoint is not calling Close after receiving the EOF signal (null) from Receive. The time allotted to this operation may have been a portion of a longer timeout. + Le point de terminaison distant du socket ({0}) n'a pas répondu à une demande de fermeture dans le délai imparti ({1}). Il est probable que le point de terminaison distant n'appelle pas Close après avoir reçu le signal EOF (null) de la part de Receive. Le temps alloué à cette opération fait peut-être partie d'un délai d'expiration plus long. + + + + The socket connection has been disposed. + La connexion au socket a été supprimée. + + + + Transfer mode {0} is not supported by {1}. + Le mode de transfert {0} n'est pas pris en charge par {1}. + + + + Could not connect to {0}. UDS error code {1}: {2}. + Could not connect to {0}. UDS error code {1}: {2}. + + + + Could not connect to {0}. The connection attempt lasted for a time span of {3}. UDS error code {1}: {2}. + Could not connect to {0}. The connection attempt lasted for a time span of {3}. UDS error code {1}: {2}. + + + + Insufficient winsock resources available to complete socket connection initiation. + Insufficient winsock resources available to complete socket connection initiation. + + + + Connecting to via {0} timed out after {1}. Connection attempts were made to {2} of {3} available addresses ({4}). Check the RemoteAddress of your channel and verify that the DNS records for this endpoint correspond to valid IP Addresses. The time allotted to this operation may have been a portion of a longer timeout. + Connecting to via {0} timed out after {1}. Connection attempts were made to {2} of {3} available addresses ({4}). Check the RemoteAddress of your channel and verify that the DNS records for this endpoint correspond to valid IP Addresses. The time allotted to this operation may have been a portion of a longer timeout. + + + + The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '{0}'. + The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '{0}'. + + + + The socket transfer timed out after {0}. You have exceeded the timeout set on your binding. The time allotted to this operation may have been a portion of a longer timeout. + The socket transfer timed out after {0}. You have exceeded the timeout set on your binding. The time allotted to this operation may have been a portion of a longer timeout. + + + + The socket connection was aborted by your local machine. This could be caused by a channel Abort(), or a transmission error from another thread using this socket. + The socket connection was aborted by your local machine. This could be caused by a channel Abort(), or a transmission error from another thread using this socket. + + + + A UDS error ({0}: {1}) occurred while transmitting data. + A UDS error ({0}: {1}) occurred while transmitting data. + + + + Cannot resolve the host name of URI "{0}" using DNS. + Impossible de résoudre le nom d'hôte de l'URI '{0}' à l'aide de DNS. + + + + The protection level '{0}' was specified, yet SSL transport security only supports EncryptAndSign. + Le niveau de protection '{0}' a été spécifié, mais la sécurité du transport SSL prend uniquement en charge EncryptAndSign. + + + + The value of this argument must be non-negative. + La valeur de cet argument doit être non négative. + + + + The value of this argument must be positive. + La valeur de cet argument doit être positive. + + + + + \ No newline at end of file diff --git a/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.it.xlf b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.it.xlf new file mode 100644 index 00000000000..6e688a89fe6 --- /dev/null +++ b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.it.xlf @@ -0,0 +1,152 @@ + + + + + + Process action '{0}'. + Elaborazione dell'azione '{0}'. + + + + The specified channel type {0} is not supported by this channel manager. + Il tipo di canale specificato {0} non è supportato da questo gestore canali. + + + + ClientCredentialType.None is not valid for the TransportWithMessageCredential security mode. Specify a message credential type or use a different security mode. + L'elemento ClientCredentialType.None non è valido per la modalità di sicurezza TransportWithMessageCredential. Specificare un tipo di credenziali messaggio o usare una modalità di sicurezza diversa. + + + + No DNS entries exist for host {0}. + Non esiste alcuna voce DNS per l'host {0}. + + + + Extended protection is not supported on this platform. Please install the appropriate patch or change the ExtendedProtectionPolicy on the Binding or BindingElement to a value with a PolicyEnforcement value of "Never" or "WhenSupported". + La protezione estesa non è supportata in questa piattaforma. Installare la patch appropriata o modificare ExtendedProtectionPolicy in Binding o BindingElement in un valore con PolicyEnforcement impostato sul valore "Never"o "WhenSupported". + + + + Insufficient memory avaliable to complete the operation. + La memoria disponibile non è sufficiente per completare l'operazione. + + + + No IPEndpoints were found for host {0}. + Non sono stati trovati elementi IPEndpoint per l'host {0}. + + + + Timeout must be greater than or equal to TimeSpan.Zero. To disable timeout, specify TimeSpan.MaxValue. + Il valore del timeout deve essere maggiore o uguale a TimeSpan.Zero. Per disabilitare il timeout, specificare TimeSpan.MaxValue. + + + + Timeouts larger than Int32.MaxValue TotalMilliseconds (approximately 24 days) cannot be honored. To disable timeout, specify TimeSpan.MaxValue. + Non è possibile rispettare i timeout in cui il valore di TotalMilliseconds è maggiore di Int32.MaxValue (circa 24 giorni). Per disabilitare il timeout, specificare TimeSpan.MaxValue. + + + + Server '{0}' sent back a fault indicating it is in the process of shutting down. Please see the inner exception for fault details. + Il server '{0}' ha restituito un errore che indica che è in fase di arresto. Per ulteriori informazioni sull'errore, vedere l'eccezione interna. + + + + Server '{0}' sent back a fault indicating it is too busy to process the request. Please retry later. Please see the inner exception for fault details. + Il server '{0}' ha restituito un errore che indica che è troppo occupato per elaborare la richiesta. Riprovare più tardi. Per dettagli sull'errore, vedere l'eccezione interna. + + + + The socket was aborted because an asynchronous receive from the socket did not complete within the allotted timeout of {0}. The time allotted to this operation may have been a portion of a longer timeout. + Il socket è stato interrotto perché una ricezione asincrona dal socket non è stata completata entro il timeout allocato pari a {0}. È possibile che il tempo allocato a questa operazione fosse incluso in un timeout più lungo. + + + + The socket connection was aborted because an asynchronous send to the socket did not complete within the allotted timeout of {0}. The time allotted to this operation may have been a portion of a longer timeout. + La connessione socket è stata interrotta perché un'operazione di invio asincrono al socket non è stata completata entro il timeout allocato pari a {0}. È possibile che il tempo allocato a questa operazione fosse incluso in un timeout più lungo. + + + + A graceful close was attempted on the socket, but the other side ({0}) is still sending data. + Si è provato a eseguire la chiusura normale sul socket, ma l'altra parte ({0}) sta ancora inviando dati. + + + + The remote endpoint of the socket ({0}) did not respond to a close request within the allotted timeout ({1}). It is likely that the remote endpoint is not calling Close after receiving the EOF signal (null) from Receive. The time allotted to this operation may have been a portion of a longer timeout. + L'endpoint remoto del socket ({0}) non ha risposto a una richiesta di chiusura entro il timeout allocato pari a ({1}). È probabile che l'endpoint remoto non stia chiamando Close dopo aver ricevuto il segnale EOF (Null) da Receive. È possibile che il tempo allocato a questa operazione fosse incluso in un timeout più lungo. + + + + The socket connection has been disposed. + La connessione socket è stata eliminata. + + + + Transfer mode {0} is not supported by {1}. + La modalità di trasferimento {0} non è supportata da {1}. + + + + Could not connect to {0}. UDS error code {1}: {2}. + Could not connect to {0}. UDS error code {1}: {2}. + + + + Could not connect to {0}. The connection attempt lasted for a time span of {3}. UDS error code {1}: {2}. + Could not connect to {0}. The connection attempt lasted for a time span of {3}. UDS error code {1}: {2}. + + + + Insufficient winsock resources available to complete socket connection initiation. + Insufficient winsock resources available to complete socket connection initiation. + + + + Connecting to via {0} timed out after {1}. Connection attempts were made to {2} of {3} available addresses ({4}). Check the RemoteAddress of your channel and verify that the DNS records for this endpoint correspond to valid IP Addresses. The time allotted to this operation may have been a portion of a longer timeout. + Connecting to via {0} timed out after {1}. Connection attempts were made to {2} of {3} available addresses ({4}). Check the RemoteAddress of your channel and verify that the DNS records for this endpoint correspond to valid IP Addresses. The time allotted to this operation may have been a portion of a longer timeout. + + + + The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '{0}'. + The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '{0}'. + + + + The socket transfer timed out after {0}. You have exceeded the timeout set on your binding. The time allotted to this operation may have been a portion of a longer timeout. + The socket transfer timed out after {0}. You have exceeded the timeout set on your binding. The time allotted to this operation may have been a portion of a longer timeout. + + + + The socket connection was aborted by your local machine. This could be caused by a channel Abort(), or a transmission error from another thread using this socket. + The socket connection was aborted by your local machine. This could be caused by a channel Abort(), or a transmission error from another thread using this socket. + + + + A UDS error ({0}: {1}) occurred while transmitting data. + A UDS error ({0}: {1}) occurred while transmitting data. + + + + Cannot resolve the host name of URI "{0}" using DNS. + Impossibile risolvere il nome host dell'URI "{0}" tramite DNS. + + + + The protection level '{0}' was specified, yet SSL transport security only supports EncryptAndSign. + È stato specificato il livello di protezione '{0}', ma la sicurezza del trasporto SSL supporta solo EncryptAndSign. + + + + The value of this argument must be non-negative. + Il valore di questo argomento non deve essere negativo. + + + + The value of this argument must be positive. + Il valore di questo argomento deve essere positivo. + + + + + \ No newline at end of file diff --git a/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.ja.xlf b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.ja.xlf new file mode 100644 index 00000000000..f8b912a2909 --- /dev/null +++ b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.ja.xlf @@ -0,0 +1,152 @@ + + + + + + Process action '{0}'. + アクション '{0}' を処理します。 + + + + The specified channel type {0} is not supported by this channel manager. + このチャネル マネージャーでは、指定されたチャネルの型 {0} をサポートしていません。 + + + + ClientCredentialType.None is not valid for the TransportWithMessageCredential security mode. Specify a message credential type or use a different security mode. + ClientCredentialType.None は、TransportWithMessageCredential セキュリティ モードでは無効です。メッセージ資格情報の種類を指定するか、別のセキュリティ モードを使用してください。 + + + + No DNS entries exist for host {0}. + ホスト {0} に対する DNS エントリが存在しません。 + + + + Extended protection is not supported on this platform. Please install the appropriate patch or change the ExtendedProtectionPolicy on the Binding or BindingElement to a value with a PolicyEnforcement value of "Never" or "WhenSupported". + このプラットフォームでは拡張保護はサポートされません。適切な更新プログラムをインストールするか、Binding または BindingElement に対する ExtendedProtectionPolicy を、"Never" または "WhenSupported" の PolicyEnforcement 値を持つ値に変更してください。 + + + + Insufficient memory avaliable to complete the operation. + 利用可能なメモリが不足しているため、この操作を完了できません。 + + + + No IPEndpoints were found for host {0}. + ホスト {0} の IPEndpoint がありませんでした。 + + + + Timeout must be greater than or equal to TimeSpan.Zero. To disable timeout, specify TimeSpan.MaxValue. + タイムアウトは TimeSpan.Zero 以上の値にする必要があります。タイムアウトを無効にするには、TimeSpan.MaxValue を指定してください。 + + + + Timeouts larger than Int32.MaxValue TotalMilliseconds (approximately 24 days) cannot be honored. To disable timeout, specify TimeSpan.MaxValue. + Int32.MaxValue TotalMilliseconds (約 24 日) よりも大きな値のタイムアウトは受け付けられません。タイムアウトを無効にするには、TimeSpan.MaxValue を指定してください。 + + + + Server '{0}' sent back a fault indicating it is in the process of shutting down. Please see the inner exception for fault details. + サーバー '{0}' は、シャットダウンの処理中であることを示すフォールトを返信しました。詳細については、内部例外を参照してください。 + + + + Server '{0}' sent back a fault indicating it is too busy to process the request. Please retry later. Please see the inner exception for fault details. + サーバー '{0}' は、ビジー状態のため要求を処理できないことを示すフォールトを送り返しました。後で再試行してください。フォールトの詳細については、内部例外を参照してください。 + + + + The socket was aborted because an asynchronous receive from the socket did not complete within the allotted timeout of {0}. The time allotted to this operation may have been a portion of a longer timeout. + 割り当てられたタイムアウト時間 {0} 内にソケットからの非同期受信が完了しなかったため、ソケットは中止されました。この操作に割り当てられた時間は、より長いタイムアウト時間の一部であった可能性があります。 + + + + The socket connection was aborted because an asynchronous send to the socket did not complete within the allotted timeout of {0}. The time allotted to this operation may have been a portion of a longer timeout. + 割り当てられたタイムアウト時間 {0} 内にソケットへの非同期送信が完了しなかったため、ソケット接続は中止されました。この操作に割り当てられた時間は、より長いタイムアウト時間の一部であった可能性があります。 + + + + A graceful close was attempted on the socket, but the other side ({0}) is still sending data. + ソケットを正常に閉じようとしましたが、相手側 ({0}) がまだデータを送信しています。 + + + + The remote endpoint of the socket ({0}) did not respond to a close request within the allotted timeout ({1}). It is likely that the remote endpoint is not calling Close after receiving the EOF signal (null) from Receive. The time allotted to this operation may have been a portion of a longer timeout. + ソケット ({0}) のリモート エンドポイントは、割り当てられたタイムアウト時間内 ({1}) に終了要求に応答しませんでした。この原因としては、リモート エンドポイントが Receive から EOF 信号 (null) を受信した後に Close を呼び出していないことが考えられます。この操作に割り当てられた時間は、より長いタイムアウト時間の一部であった可能性があります。 + + + + The socket connection has been disposed. + ソケット接続は破棄されています。 + + + + Transfer mode {0} is not supported by {1}. + 転送モード {0} は {1} でサポートされていません。 + + + + Could not connect to {0}. UDS error code {1}: {2}. + Could not connect to {0}. UDS error code {1}: {2}. + + + + Could not connect to {0}. The connection attempt lasted for a time span of {3}. UDS error code {1}: {2}. + Could not connect to {0}. The connection attempt lasted for a time span of {3}. UDS error code {1}: {2}. + + + + Insufficient winsock resources available to complete socket connection initiation. + Insufficient winsock resources available to complete socket connection initiation. + + + + Connecting to via {0} timed out after {1}. Connection attempts were made to {2} of {3} available addresses ({4}). Check the RemoteAddress of your channel and verify that the DNS records for this endpoint correspond to valid IP Addresses. The time allotted to this operation may have been a portion of a longer timeout. + Connecting to via {0} timed out after {1}. Connection attempts were made to {2} of {3} available addresses ({4}). Check the RemoteAddress of your channel and verify that the DNS records for this endpoint correspond to valid IP Addresses. The time allotted to this operation may have been a portion of a longer timeout. + + + + The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '{0}'. + The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '{0}'. + + + + The socket transfer timed out after {0}. You have exceeded the timeout set on your binding. The time allotted to this operation may have been a portion of a longer timeout. + The socket transfer timed out after {0}. You have exceeded the timeout set on your binding. The time allotted to this operation may have been a portion of a longer timeout. + + + + The socket connection was aborted by your local machine. This could be caused by a channel Abort(), or a transmission error from another thread using this socket. + The socket connection was aborted by your local machine. This could be caused by a channel Abort(), or a transmission error from another thread using this socket. + + + + A UDS error ({0}: {1}) occurred while transmitting data. + A UDS error ({0}: {1}) occurred while transmitting data. + + + + Cannot resolve the host name of URI "{0}" using DNS. + DNS を使用して URI "{0}" のホスト名を解決できません。 + + + + The protection level '{0}' was specified, yet SSL transport security only supports EncryptAndSign. + 保護レベル '{0}' が指定されましたが、SSL トランスポート セキュリティでサポートされるのは EncryptAndSign のみです。 + + + + The value of this argument must be non-negative. + この引数の値は、負ではない値である必要があります。 + + + + The value of this argument must be positive. + この引数の値は、正の値である必要があります。 + + + + + \ No newline at end of file diff --git a/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.ko.xlf b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.ko.xlf new file mode 100644 index 00000000000..d70a7b9ac03 --- /dev/null +++ b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.ko.xlf @@ -0,0 +1,152 @@ + + + + + + Process action '{0}'. + 동작 '{0}'을(를) 처리하세요. + + + + The specified channel type {0} is not supported by this channel manager. + 지정된 채널 형식 {0}이(가) 이 채널 관리자에서 지원되지 않습니다. + + + + ClientCredentialType.None is not valid for the TransportWithMessageCredential security mode. Specify a message credential type or use a different security mode. + ClientCredentialType.None은 TransportWithMessageCredential 보안 모드에 사용할 수 없습니다. 메시지 자격 증명 형식을 지정하거나 다른 보안 모드를 사용하세요. + + + + No DNS entries exist for host {0}. + 호스트 {0}에 대한 DNS 항목이 없습니다. + + + + Extended protection is not supported on this platform. Please install the appropriate patch or change the ExtendedProtectionPolicy on the Binding or BindingElement to a value with a PolicyEnforcement value of "Never" or "WhenSupported". + 이 플랫폼에서는 확장된 보호가 지원되지 않습니다. 적합한 패치를 설치하거나 Binding 또는 BindingElement의 ExtendedProtectionPolicy를 PolicyEnforcement 값이 "Never" 또는 "WhenSupported"인 값으로 변경하십시오. + + + + Insufficient memory avaliable to complete the operation. + 작업을 완료하는 데 사용할 수 있는 메모리가 부족합니다. + + + + No IPEndpoints were found for host {0}. + 호스트 {0}에 대한 IPEndpoints를 찾을 수 없습니다. + + + + Timeout must be greater than or equal to TimeSpan.Zero. To disable timeout, specify TimeSpan.MaxValue. + 제한 시간은 TimeSpan.Zero보다 크거나 같아야 합니다. 제한 시간을 사용하지 않도록 설정하려면 TimeSpan.MaxValue를 지정하세요. + + + + Timeouts larger than Int32.MaxValue TotalMilliseconds (approximately 24 days) cannot be honored. To disable timeout, specify TimeSpan.MaxValue. + Int32.MaxValue TotalMilliseconds(약 24일)보다 큰 시간 제한은 허용되지 않습니다. 시간 제한을 사용하지 않으려면 TimeSpan.MaxValue를 지정하세요. + + + + Server '{0}' sent back a fault indicating it is in the process of shutting down. Please see the inner exception for fault details. + 종료하는 중이라는 것을 나타내는 오류를 '{0}' 서버가 다시 보냈습니다. 자세한 오류 내용은 내부 예외를 참조하십시오. + + + + Server '{0}' sent back a fault indicating it is too busy to process the request. Please retry later. Please see the inner exception for fault details. + 사용 중이어서 요청을 처리할 수 없다는 것을 나타내는 오류를 '{0}' 서버가 다시 보냈습니다. 나중에 다시 시도하세요. 자세한 오류 내용은 내부 예외를 참조하세요. + + + + The socket was aborted because an asynchronous receive from the socket did not complete within the allotted timeout of {0}. The time allotted to this operation may have been a portion of a longer timeout. + 소켓에서의 비동기 수신이 할당된 시간 제한({0}) 내에 완료되지 않았으므로 소켓이 중단되었습니다. 이 작업에 할당된 시간이 보다 긴 시간 제한의 일부일 수 있습니다. + + + + The socket connection was aborted because an asynchronous send to the socket did not complete within the allotted timeout of {0}. The time allotted to this operation may have been a portion of a longer timeout. + 소켓으로의 비동기 발신이 할당된 시간 제한({0}) 내에 완료되지 않았으므로 소켓 연결이 중단되었습니다. 이 작업에 할당된 시간이 보다 긴 시간 제한의 일부일 수 있습니다. + + + + A graceful close was attempted on the socket, but the other side ({0}) is still sending data. + 소켓에서 정상적인 닫기를 시도했지만, 다른 쪽({0})에서 아직 데이터를 보내고 있습니다. + + + + The remote endpoint of the socket ({0}) did not respond to a close request within the allotted timeout ({1}). It is likely that the remote endpoint is not calling Close after receiving the EOF signal (null) from Receive. The time allotted to this operation may have been a portion of a longer timeout. + 소켓({0})의 원격 끝점이 할당된 시간 제한({1}) 내에 닫기 요청에 응답하지 않았습니다. Receive에서 EOF 신호(null)를 받은 후에 원격 끝점이 Close를 호출하지 않는 것으로 보입니다. 이 작업에 할당된 시간이 보다 긴 시간 제한의 일부일 수 있습니다. + + + + The socket connection has been disposed. + 소켓 연결이 삭제되었습니다. + + + + Transfer mode {0} is not supported by {1}. + 전송 모드 {0}을(를) {1}에서 지원하지 않습니다. + + + + Could not connect to {0}. UDS error code {1}: {2}. + Could not connect to {0}. UDS error code {1}: {2}. + + + + Could not connect to {0}. The connection attempt lasted for a time span of {3}. UDS error code {1}: {2}. + Could not connect to {0}. The connection attempt lasted for a time span of {3}. UDS error code {1}: {2}. + + + + Insufficient winsock resources available to complete socket connection initiation. + Insufficient winsock resources available to complete socket connection initiation. + + + + Connecting to via {0} timed out after {1}. Connection attempts were made to {2} of {3} available addresses ({4}). Check the RemoteAddress of your channel and verify that the DNS records for this endpoint correspond to valid IP Addresses. The time allotted to this operation may have been a portion of a longer timeout. + Connecting to via {0} timed out after {1}. Connection attempts were made to {2} of {3} available addresses ({4}). Check the RemoteAddress of your channel and verify that the DNS records for this endpoint correspond to valid IP Addresses. The time allotted to this operation may have been a portion of a longer timeout. + + + + The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '{0}'. + The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '{0}'. + + + + The socket transfer timed out after {0}. You have exceeded the timeout set on your binding. The time allotted to this operation may have been a portion of a longer timeout. + The socket transfer timed out after {0}. You have exceeded the timeout set on your binding. The time allotted to this operation may have been a portion of a longer timeout. + + + + The socket connection was aborted by your local machine. This could be caused by a channel Abort(), or a transmission error from another thread using this socket. + The socket connection was aborted by your local machine. This could be caused by a channel Abort(), or a transmission error from another thread using this socket. + + + + A UDS error ({0}: {1}) occurred while transmitting data. + A UDS error ({0}: {1}) occurred while transmitting data. + + + + Cannot resolve the host name of URI "{0}" using DNS. + DNS를 사용하여 URI "{0}"의 호스트 이름을 확인할 수 없습니다. + + + + The protection level '{0}' was specified, yet SSL transport security only supports EncryptAndSign. + 보호 수준 '{0}'이(가) 지정되었지만, SSL 전송 보안은 EncryptAndSign만 지원합니다. + + + + The value of this argument must be non-negative. + 이 인수의 값은 음수가 아니어야 합니다. + + + + The value of this argument must be positive. + 이 인수의 값은 양수여야 합니다. + + + + + \ No newline at end of file diff --git a/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.pl.xlf b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.pl.xlf new file mode 100644 index 00000000000..858512bc044 --- /dev/null +++ b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.pl.xlf @@ -0,0 +1,152 @@ + + + + + + Process action '{0}'. + Przetwarzaj akcję „{0}”. + + + + The specified channel type {0} is not supported by this channel manager. + Określony typ kanału {0} jest nieobsługiwany przez tego menedżera kanałów. + + + + ClientCredentialType.None is not valid for the TransportWithMessageCredential security mode. Specify a message credential type or use a different security mode. + Wartość ClientCredentialType.None jest niepoprawna dla trybu zabezpieczeń TransportWithMessageCredential. Określ typ poświadczeń komunikatu lub użyj innego trybu zabezpieczeń. + + + + No DNS entries exist for host {0}. + Brak wpisów DNS dla hosta {0}. + + + + Extended protection is not supported on this platform. Please install the appropriate patch or change the ExtendedProtectionPolicy on the Binding or BindingElement to a value with a PolicyEnforcement value of "Never" or "WhenSupported". + Ochrona rozszerzona jest nieobsługiwana na tej platformie. Zainstaluj odpowiednią poprawkę lub zmień wartość właściwości ExtendedProtectionPolicy obiektu Binding lub BindingElement na właściwość PolicyEnforcement o wartości Never lub WhenSupported. + + + + Insufficient memory avaliable to complete the operation. + Brak wystarczającej ilości pamięci, aby ukończyć operację. + + + + No IPEndpoints were found for host {0}. + Nie znaleziono elementów IPEndpoints dla hosta {0}. + + + + Timeout must be greater than or equal to TimeSpan.Zero. To disable timeout, specify TimeSpan.MaxValue. + Limit czasu musi być większy lub równy wartości TimeSpan.Zero. Aby wyłączyć limit czasu, określ wartość TimeSpan.MaxValue. + + + + Timeouts larger than Int32.MaxValue TotalMilliseconds (approximately 24 days) cannot be honored. To disable timeout, specify TimeSpan.MaxValue. + Limity czasu większe niż Int32.MaxValue TotalMilliseconds (około 24 dni) nie mogą być uwzględniane. Aby wyłączyć limit czasu, określ wartość TimeSpan.MaxValue. + + + + Server '{0}' sent back a fault indicating it is in the process of shutting down. Please see the inner exception for fault details. + Serwer „{0}” zwrócił błąd wskazujący, że właśnie trwa jego zamykanie. Szczegółowe informacje o błędzie można znaleźć w wewnętrznym wyjątku. + + + + Server '{0}' sent back a fault indicating it is too busy to process the request. Please retry later. Please see the inner exception for fault details. + Serwer „{0}” zwrócił błąd wskazujący, że jest zbyt obciążony, aby obsłużyć żądanie. Spróbuj ponownie później. Szczegółowe informacje o błędzie można znaleźć w wewnętrznym wyjątku. + + + + The socket was aborted because an asynchronous receive from the socket did not complete within the allotted timeout of {0}. The time allotted to this operation may have been a portion of a longer timeout. + Gniazdo zostało anulowane, ponieważ operacja asynchronicznego odbioru z gniazda nie zakończyła się w ciągu przydzielonego limitu czasu {0}. Czas przydzielony na tę operację mógł być częścią dłuższego limitu czasu. + + + + The socket connection was aborted because an asynchronous send to the socket did not complete within the allotted timeout of {0}. The time allotted to this operation may have been a portion of a longer timeout. + Połączenie gniazda zostało anulowane, ponieważ operacja asynchronicznego wysyłania do gniazda nie zakończyła się w ciągu przydzielonego limitu czasu {0}. Czas przydzielony na tę operację mógł być częścią dłuższego limitu czasu. + + + + A graceful close was attempted on the socket, but the other side ({0}) is still sending data. + Na gnieździe wykonano operację prawidłowego zamknięcia, ale druga strona ({0}) nadal wysyła dane. + + + + The remote endpoint of the socket ({0}) did not respond to a close request within the allotted timeout ({1}). It is likely that the remote endpoint is not calling Close after receiving the EOF signal (null) from Receive. The time allotted to this operation may have been a portion of a longer timeout. + Zdalny punkt końcowy gniazda ({0}) nie odpowiedział na żądanie zamknięcia w ciągu przydzielonego limitu czasu ({1}). Zdalny punkt końcowy prawdopodobnie nie wywołuje metody Close po odebraniu sygnału EOF (null) z metody Receive. Czas przydzielony na tę operację mógł być częścią dłuższego limitu czasu. + + + + The socket connection has been disposed. + Połączenie gniazda zostało usunięte. + + + + Transfer mode {0} is not supported by {1}. + Tryb transferu {0} nie jest obsługiwany przez element {1}. + + + + Could not connect to {0}. UDS error code {1}: {2}. + Could not connect to {0}. UDS error code {1}: {2}. + + + + Could not connect to {0}. The connection attempt lasted for a time span of {3}. UDS error code {1}: {2}. + Could not connect to {0}. The connection attempt lasted for a time span of {3}. UDS error code {1}: {2}. + + + + Insufficient winsock resources available to complete socket connection initiation. + Insufficient winsock resources available to complete socket connection initiation. + + + + Connecting to via {0} timed out after {1}. Connection attempts were made to {2} of {3} available addresses ({4}). Check the RemoteAddress of your channel and verify that the DNS records for this endpoint correspond to valid IP Addresses. The time allotted to this operation may have been a portion of a longer timeout. + Connecting to via {0} timed out after {1}. Connection attempts were made to {2} of {3} available addresses ({4}). Check the RemoteAddress of your channel and verify that the DNS records for this endpoint correspond to valid IP Addresses. The time allotted to this operation may have been a portion of a longer timeout. + + + + The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '{0}'. + The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '{0}'. + + + + The socket transfer timed out after {0}. You have exceeded the timeout set on your binding. The time allotted to this operation may have been a portion of a longer timeout. + The socket transfer timed out after {0}. You have exceeded the timeout set on your binding. The time allotted to this operation may have been a portion of a longer timeout. + + + + The socket connection was aborted by your local machine. This could be caused by a channel Abort(), or a transmission error from another thread using this socket. + The socket connection was aborted by your local machine. This could be caused by a channel Abort(), or a transmission error from another thread using this socket. + + + + A UDS error ({0}: {1}) occurred while transmitting data. + A UDS error ({0}: {1}) occurred while transmitting data. + + + + Cannot resolve the host name of URI "{0}" using DNS. + Nie można rozpoznać nazwy hosta o identyfikatorze URI „{0}” za pomocą usługi DNS. + + + + The protection level '{0}' was specified, yet SSL transport security only supports EncryptAndSign. + Określono poziom zabezpieczeń „{0}”, jednak zabezpieczenia transportowe protokołu SSL obsługują tylko metodę EncryptAndSign. + + + + The value of this argument must be non-negative. + Wartość tego argumentu nie może być ujemna. + + + + The value of this argument must be positive. + Wartość tego argumentu musi być dodatnia. + + + + + \ No newline at end of file diff --git a/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.pt-BR.xlf b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.pt-BR.xlf new file mode 100644 index 00000000000..165daebcaf3 --- /dev/null +++ b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.pt-BR.xlf @@ -0,0 +1,152 @@ + + + + + + Process action '{0}'. + Processar a ação '{0}'. + + + + The specified channel type {0} is not supported by this channel manager. + O tipo de canal especificado {0} não tem suporte deste gerenciador de canais. + + + + ClientCredentialType.None is not valid for the TransportWithMessageCredential security mode. Specify a message credential type or use a different security mode. + ClientCredentialType.None inválido para o modo de segurança TransportWithMessageCredential. Especifique um tipo de credencial de mensagem ou use um modo de segurança diferente. + + + + No DNS entries exist for host {0}. + Não existem entradas DNS para o host {0}. + + + + Extended protection is not supported on this platform. Please install the appropriate patch or change the ExtendedProtectionPolicy on the Binding or BindingElement to a value with a PolicyEnforcement value of "Never" or "WhenSupported". + A proteção estendida não é suportada nesta plataforma. Instale o patch apropriado ou altere a ExtendedProtectionPolicy em Binding ou BindingElement para um valor com PolicyEnforcement definido como "Never" ou "WhenSupported". + + + + Insufficient memory avaliable to complete the operation. + Memória insuficiente disponível para concluir a operação. + + + + No IPEndpoints were found for host {0}. + Não foi possível encontrar IPEndpoints para o host {0}. + + + + Timeout must be greater than or equal to TimeSpan.Zero. To disable timeout, specify TimeSpan.MaxValue. + O tempo limite deve ser maior ou igual a TimeSpan.Zero. Para desabilitar o tempo limite, especifique TimeSpan.MaxValue. + + + + Timeouts larger than Int32.MaxValue TotalMilliseconds (approximately 24 days) cannot be honored. To disable timeout, specify TimeSpan.MaxValue. + Os tempos limites maiores que Int32.MaxValue TotalMilliseconds (aproximadamente 24 dias) não podem ser honrados. Para desabilitar o tempo limite, especifique TimeSpan.MaxValue. + + + + Server '{0}' sent back a fault indicating it is in the process of shutting down. Please see the inner exception for fault details. + O servidor '{0}' retornou uma falha indicando que ele está desligando. Consulte a exceção interna para obter os detalhes da falha. + + + + Server '{0}' sent back a fault indicating it is too busy to process the request. Please retry later. Please see the inner exception for fault details. + O servidor '{0}' retornou uma falha indicando que ele está muito ocupado para processar a solicitação. Tente novamente mais tarde. Consulte a exceção interna para obter os detalhes da falha. + + + + The socket was aborted because an asynchronous receive from the socket did not complete within the allotted timeout of {0}. The time allotted to this operation may have been a portion of a longer timeout. + O soquete foi anulado porque uma recepção assíncrona do soquete não foi concluída no tempo limite alocado de {0}. O tempo alocado para essa operação pode ter sido uma parte de um tempo limite maior. + + + + The socket connection was aborted because an asynchronous send to the socket did not complete within the allotted timeout of {0}. The time allotted to this operation may have been a portion of a longer timeout. + A conexão de soquete foi anulada porque um envio assíncrono para o soquete não foi concluído no tempo limite alocado de {0}. O tempo alocado para essa operação pode ter sido uma parte de um tempo limite maior. + + + + A graceful close was attempted on the socket, but the other side ({0}) is still sending data. + Tentativa de fechamento normal no soquete, mas o outro lado ({0}) ainda está enviando dados. + + + + The remote endpoint of the socket ({0}) did not respond to a close request within the allotted timeout ({1}). It is likely that the remote endpoint is not calling Close after receiving the EOF signal (null) from Receive. The time allotted to this operation may have been a portion of a longer timeout. + O ponto de extremidade remoto do soquete ({0}) não respondeu a uma solicitação de fechamento no tempo limite alocado ({1}). É provável que o ponto de extremidade remoto não esteja chamando Close após receber o sinal EOF (nulo) de Receive. O tempo alocado para essa operação pode ter sido uma parte de um tempo limite maior. + + + + The socket connection has been disposed. + A conexão de soquete foi descartada. + + + + Transfer mode {0} is not supported by {1}. + O modo de transferência {0} não tem suporte em {1}. + + + + Could not connect to {0}. UDS error code {1}: {2}. + Could not connect to {0}. UDS error code {1}: {2}. + + + + Could not connect to {0}. The connection attempt lasted for a time span of {3}. UDS error code {1}: {2}. + Could not connect to {0}. The connection attempt lasted for a time span of {3}. UDS error code {1}: {2}. + + + + Insufficient winsock resources available to complete socket connection initiation. + Insufficient winsock resources available to complete socket connection initiation. + + + + Connecting to via {0} timed out after {1}. Connection attempts were made to {2} of {3} available addresses ({4}). Check the RemoteAddress of your channel and verify that the DNS records for this endpoint correspond to valid IP Addresses. The time allotted to this operation may have been a portion of a longer timeout. + Connecting to via {0} timed out after {1}. Connection attempts were made to {2} of {3} available addresses ({4}). Check the RemoteAddress of your channel and verify that the DNS records for this endpoint correspond to valid IP Addresses. The time allotted to this operation may have been a portion of a longer timeout. + + + + The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '{0}'. + The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '{0}'. + + + + The socket transfer timed out after {0}. You have exceeded the timeout set on your binding. The time allotted to this operation may have been a portion of a longer timeout. + The socket transfer timed out after {0}. You have exceeded the timeout set on your binding. The time allotted to this operation may have been a portion of a longer timeout. + + + + The socket connection was aborted by your local machine. This could be caused by a channel Abort(), or a transmission error from another thread using this socket. + The socket connection was aborted by your local machine. This could be caused by a channel Abort(), or a transmission error from another thread using this socket. + + + + A UDS error ({0}: {1}) occurred while transmitting data. + A UDS error ({0}: {1}) occurred while transmitting data. + + + + Cannot resolve the host name of URI "{0}" using DNS. + Não é possível resolver nome de host de URI "{0}" usando DNS. + + + + The protection level '{0}' was specified, yet SSL transport security only supports EncryptAndSign. + O nível de proteção '{0}' foi especificado, ainda assim a segurança do transporte SSL apenas dá suporte a EncryptAndSign. + + + + The value of this argument must be non-negative. + O valor deste argumento não deve ser negativo. + + + + The value of this argument must be positive. + O valor deste argumento deve ser positivo. + + + + + \ No newline at end of file diff --git a/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.ru.xlf b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.ru.xlf new file mode 100644 index 00000000000..7ec68b6e857 --- /dev/null +++ b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.ru.xlf @@ -0,0 +1,152 @@ + + + + + + Process action '{0}'. + Обработка действия "{0}". + + + + The specified channel type {0} is not supported by this channel manager. + Указанный тип канала {0} не поддерживается данным диспетчером каналов. + + + + ClientCredentialType.None is not valid for the TransportWithMessageCredential security mode. Specify a message credential type or use a different security mode. + ClientCredentialType.None недопустим в режиме безопасности TransportWithMessageCredential. Укажите тип учетных данных сообщения или используйте другой режим безопасности. + + + + No DNS entries exist for host {0}. + Нет никаких записей DNS для узла {0}. + + + + Extended protection is not supported on this platform. Please install the appropriate patch or change the ExtendedProtectionPolicy on the Binding or BindingElement to a value with a PolicyEnforcement value of "Never" or "WhenSupported". + Расширенная защита на этой платформе не поддерживается. Установите соответствующее обновление или измените политику ExtendedProtectionPolicy на привязке либо элемент BindingElement на значение PolicyEnforcement "Never" или "WhenSupported". + + + + Insufficient memory avaliable to complete the operation. + Недостаточно памяти для завершения операции. + + + + No IPEndpoints were found for host {0}. + Для узла {0} точки IPEndpoints не найдены. + + + + Timeout must be greater than or equal to TimeSpan.Zero. To disable timeout, specify TimeSpan.MaxValue. + Время ожидания должно быть не менее TimeSpan.Zero. Чтобы отключить время ожидания, укажите TimeSpan.MaxValue. + + + + Timeouts larger than Int32.MaxValue TotalMilliseconds (approximately 24 days) cannot be honored. To disable timeout, specify TimeSpan.MaxValue. + Время ожидания, превышающее Int32.MaxValue TotalMilliseconds (приблизительно 24 дня), не учитывается. Чтобы отключить время ожидания, укажите TimeSpan.MaxValue. + + + + Server '{0}' sent back a fault indicating it is in the process of shutting down. Please see the inner exception for fault details. + Сервер "{0}" отправил обратно сообщение об ошибке, указывающее, что он находится в процессе отключения. Дополнительные сведения об ошибке см. внутреннее исключение. + + + + Server '{0}' sent back a fault indicating it is too busy to process the request. Please retry later. Please see the inner exception for fault details. + Сервер "{0}" отправил обратно сообщение об ошибке, указывающее, что он перегружен и не может обработать запрос. Повторите попытку позже. Дополнительные сведения об ошибке см. в описании внутреннего исключения. + + + + The socket was aborted because an asynchronous receive from the socket did not complete within the allotted timeout of {0}. The time allotted to this operation may have been a portion of a longer timeout. + Работа сокета была прервана, так как асинхронный прием через сокет не был завершен в течение указанного периода ожидания {0}. Время, выделенное для выполнения этой операции, может быть составной частью более длительного времени ожидания. + + + + The socket connection was aborted because an asynchronous send to the socket did not complete within the allotted timeout of {0}. The time allotted to this operation may have been a portion of a longer timeout. + Подключение к сокету прервано, так как асинхронная отправка через сокет не завершилась в течение указанного периода ожидания {0}. Время, выделенное для выполнения этой операции, может быть составной частью более длительного времени ожидания. + + + + A graceful close was attempted on the socket, but the other side ({0}) is still sending data. + Произведена попытка мягкого закрытия сокета, однако другая сторона ({0}) продолжает отправку данных. + + + + The remote endpoint of the socket ({0}) did not respond to a close request within the allotted timeout ({1}). It is likely that the remote endpoint is not calling Close after receiving the EOF signal (null) from Receive. The time allotted to this operation may have been a portion of a longer timeout. + Удаленная конечная точка сокета ({0}) не ответила на запрос закрытия в течение установленного времени ожидания ({1}). Возможно, удаленная конечная точка не вызывает Close после получения сигнала конца файла EOF (null) от Receive. Время, выделенное для выполнения этой операции, может быть составной частью более длительного времени ожидания. + + + + The socket connection has been disposed. + Подключение к сокету было ликвидировано. + + + + Transfer mode {0} is not supported by {1}. + {1} не поддерживает режим передачи {0}. + + + + Could not connect to {0}. UDS error code {1}: {2}. + Could not connect to {0}. UDS error code {1}: {2}. + + + + Could not connect to {0}. The connection attempt lasted for a time span of {3}. UDS error code {1}: {2}. + Could not connect to {0}. The connection attempt lasted for a time span of {3}. UDS error code {1}: {2}. + + + + Insufficient winsock resources available to complete socket connection initiation. + Insufficient winsock resources available to complete socket connection initiation. + + + + Connecting to via {0} timed out after {1}. Connection attempts were made to {2} of {3} available addresses ({4}). Check the RemoteAddress of your channel and verify that the DNS records for this endpoint correspond to valid IP Addresses. The time allotted to this operation may have been a portion of a longer timeout. + Connecting to via {0} timed out after {1}. Connection attempts were made to {2} of {3} available addresses ({4}). Check the RemoteAddress of your channel and verify that the DNS records for this endpoint correspond to valid IP Addresses. The time allotted to this operation may have been a portion of a longer timeout. + + + + The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '{0}'. + The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '{0}'. + + + + The socket transfer timed out after {0}. You have exceeded the timeout set on your binding. The time allotted to this operation may have been a portion of a longer timeout. + The socket transfer timed out after {0}. You have exceeded the timeout set on your binding. The time allotted to this operation may have been a portion of a longer timeout. + + + + The socket connection was aborted by your local machine. This could be caused by a channel Abort(), or a transmission error from another thread using this socket. + The socket connection was aborted by your local machine. This could be caused by a channel Abort(), or a transmission error from another thread using this socket. + + + + A UDS error ({0}: {1}) occurred while transmitting data. + A UDS error ({0}: {1}) occurred while transmitting data. + + + + Cannot resolve the host name of URI "{0}" using DNS. + Не удается разрешить имя узла URI "{0}" с помощью DNS. + + + + The protection level '{0}' was specified, yet SSL transport security only supports EncryptAndSign. + Указан уровень защиты "{0}", однако защита транспорта SSL поддерживает только EncryptAndSign. + + + + The value of this argument must be non-negative. + Значение этого аргумента должно быть неотрицательным. + + + + The value of this argument must be positive. + Значение этого аргумента должно быть положительным. + + + + + \ No newline at end of file diff --git a/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.tr.xlf b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.tr.xlf new file mode 100644 index 00000000000..78dd48c3ef1 --- /dev/null +++ b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.tr.xlf @@ -0,0 +1,152 @@ + + + + + + Process action '{0}'. + '{0}' eylemini işleyin. + + + + The specified channel type {0} is not supported by this channel manager. + Belirtilen kanal türü {0}, bu kanal yöneticisi tarafından desteklenmiyor. + + + + ClientCredentialType.None is not valid for the TransportWithMessageCredential security mode. Specify a message credential type or use a different security mode. + ClientCredentialType.None, TransportWithMessageCredential güvenlik modu için geçerli değil. Bir ileti kimlik bilgisi türü belirtin ya da farklı bir güvenlik modu kullanın. + + + + No DNS entries exist for host {0}. + {0} konağı için DNS girdisi yok. + + + + Extended protection is not supported on this platform. Please install the appropriate patch or change the ExtendedProtectionPolicy on the Binding or BindingElement to a value with a PolicyEnforcement value of "Never" or "WhenSupported". + Genişletilmiş koruma bu platformda desteklenmez. Lütfen uygun düzeltme ekini yükleyin veya Binding veya BindingElement üzerindeki ExtendedProtectionPolicy öğesini, PolicyEnforcement değeri "Never" veya "WhenSupported" olan bir değere değiştirin. + + + + Insufficient memory avaliable to complete the operation. + İşlemi tamamlamak için yetersiz kullanılabilir bellek. + + + + No IPEndpoints were found for host {0}. + {0} konağı için IPEndpoints bulunamadı. + + + + Timeout must be greater than or equal to TimeSpan.Zero. To disable timeout, specify TimeSpan.MaxValue. + Zaman aşımı değeri, TimeSpan.Zero değerinden büyük ya da ona eşit olmalıdır. Zaman aşımını devre dışı bırakmak için TimeSpan.MaxValue değeri belirtin. + + + + Timeouts larger than Int32.MaxValue TotalMilliseconds (approximately 24 days) cannot be honored. To disable timeout, specify TimeSpan.MaxValue. + Int32.MaxValue TotalMilliseconds (yaklaşık 24 gün) değerinden büyük zaman aşımı değerleri dikkate alınmaz. Zaman aşımını devre dışı bırakmak için TimeSpan.MaxValue değeri belirtin. + + + + Server '{0}' sent back a fault indicating it is in the process of shutting down. Please see the inner exception for fault details. + '{0}' sunucusu, kapanmakta olduğunu belirten bir hata gönderdi. Hata ayrıntıları için iç özel duruma bakın. + + + + Server '{0}' sent back a fault indicating it is too busy to process the request. Please retry later. Please see the inner exception for fault details. + '{0}' sunucusu bir hata geri göndererek, isteği işleyemeyecek kadar meşgul olduğunu belirtti. Lütfen daha sonra yeniden deneyin. Hata ayrıntıları için iç özel duruma bakın. + + + + The socket was aborted because an asynchronous receive from the socket did not complete within the allotted timeout of {0}. The time allotted to this operation may have been a portion of a longer timeout. + Asenkron bir yuvadan alma işlemi ayrılan {0} zaman aşımı süresi içinde tamamlanamadığından, yuva iptal edildi. Bu işlem için ayrılan süre daha uzun bir zaman aşımı değerinin bir bölümü olabilir. + + + + The socket connection was aborted because an asynchronous send to the socket did not complete within the allotted timeout of {0}. The time allotted to this operation may have been a portion of a longer timeout. + Asenkron bir yuvaya gönderme işlemi ayrılan zaman aşımı süresi {0} içinde tamamlanamadığından, yuva bağlantısı iptal edildi. Bu işlem için ayrılan süre daha uzun bir zaman aşımı değerinin bir bölümü olabilir. + + + + A graceful close was attempted on the socket, but the other side ({0}) is still sending data. + Yuva normal biçimde kapatılmaya çalışıldı, ancak diğer taraf ({0}) hala veri gönderiyor. + + + + The remote endpoint of the socket ({0}) did not respond to a close request within the allotted timeout ({1}). It is likely that the remote endpoint is not calling Close after receiving the EOF signal (null) from Receive. The time allotted to this operation may have been a portion of a longer timeout. + Yuvanın uzak uç noktası ({0}), ayrılan zaman aşımı süresi ({1}) bir kapatma isteğini yanıtlamadı. Büyük olasılıkla, uzak uç nokta Receive işlevinden EOF sinyalini (null) aldıktan sonra Close çağrısı yapmıyor. Bu işlem için ayrılan süre daha uzun bir zaman aşımı değerinin bir bölümü olabilir. + + + + The socket connection has been disposed. + Yuva bağlantısı atıldı. + + + + Transfer mode {0} is not supported by {1}. + {0} aktarma modu, {1} tarafından desteklenmiyor. + + + + Could not connect to {0}. UDS error code {1}: {2}. + Could not connect to {0}. UDS error code {1}: {2}. + + + + Could not connect to {0}. The connection attempt lasted for a time span of {3}. UDS error code {1}: {2}. + Could not connect to {0}. The connection attempt lasted for a time span of {3}. UDS error code {1}: {2}. + + + + Insufficient winsock resources available to complete socket connection initiation. + Insufficient winsock resources available to complete socket connection initiation. + + + + Connecting to via {0} timed out after {1}. Connection attempts were made to {2} of {3} available addresses ({4}). Check the RemoteAddress of your channel and verify that the DNS records for this endpoint correspond to valid IP Addresses. The time allotted to this operation may have been a portion of a longer timeout. + Connecting to via {0} timed out after {1}. Connection attempts were made to {2} of {3} available addresses ({4}). Check the RemoteAddress of your channel and verify that the DNS records for this endpoint correspond to valid IP Addresses. The time allotted to this operation may have been a portion of a longer timeout. + + + + The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '{0}'. + The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '{0}'. + + + + The socket transfer timed out after {0}. You have exceeded the timeout set on your binding. The time allotted to this operation may have been a portion of a longer timeout. + The socket transfer timed out after {0}. You have exceeded the timeout set on your binding. The time allotted to this operation may have been a portion of a longer timeout. + + + + The socket connection was aborted by your local machine. This could be caused by a channel Abort(), or a transmission error from another thread using this socket. + The socket connection was aborted by your local machine. This could be caused by a channel Abort(), or a transmission error from another thread using this socket. + + + + A UDS error ({0}: {1}) occurred while transmitting data. + A UDS error ({0}: {1}) occurred while transmitting data. + + + + Cannot resolve the host name of URI "{0}" using DNS. + DNS kullanılarak URI "{0}" ana bilgisayar adı çözümlenemiyor. + + + + The protection level '{0}' was specified, yet SSL transport security only supports EncryptAndSign. + SSL aktarım güvenliği yalnızca EncryptAndSign özelliğini desteklese de, '{0}' koruma düzeyi belirtildi. + + + + The value of this argument must be non-negative. + Bu bağımsız değişkenin değeri negatif olmamalıdır. + + + + The value of this argument must be positive. + Bu bağımsız değişkenin değeri pozitif olmalıdır. + + + + + \ No newline at end of file diff --git a/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.zh-Hans.xlf b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.zh-Hans.xlf new file mode 100644 index 00000000000..54def095f6c --- /dev/null +++ b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.zh-Hans.xlf @@ -0,0 +1,152 @@ + + + + + + Process action '{0}'. + 处理操作“{0}”。 + + + + The specified channel type {0} is not supported by this channel manager. + 此通道管理器不支持指定的通道类型 {0}。 + + + + ClientCredentialType.None is not valid for the TransportWithMessageCredential security mode. Specify a message credential type or use a different security mode. + ClientCredentialType.None 对于 TransportWithMessageCredential 安全模式无效。请指定消息凭据类型或使用其他安全模式。 + + + + No DNS entries exist for host {0}. + 主机 {0} 不存在 DNS 条目。 + + + + Extended protection is not supported on this platform. Please install the appropriate patch or change the ExtendedProtectionPolicy on the Binding or BindingElement to a value with a PolicyEnforcement value of "Never" or "WhenSupported". + 此平台上不支持扩展保护。请安装适当的修补程序,或者将 Binding 或 BindingElement 上的 ExtendedProtectionPolicy 更改为 PolicyEnforcement 值为“Never”或“WhenSupported”的某个值。 + + + + Insufficient memory avaliable to complete the operation. + 可用内存不足,无法完成操作。 + + + + No IPEndpoints were found for host {0}. + 找不到主机 {0} 的任何 IPEndpoints。 + + + + Timeout must be greater than or equal to TimeSpan.Zero. To disable timeout, specify TimeSpan.MaxValue. + 超时必须大于或等于 TimeSpan.Zero。要禁用超时,请指定 TimeSpan.MaxValue。 + + + + Timeouts larger than Int32.MaxValue TotalMilliseconds (approximately 24 days) cannot be honored. To disable timeout, specify TimeSpan.MaxValue. + 无法处理大于 Int32.MaxValue TotalMilliseconds (大约 24 天)的超时。要禁用超时,请指定 TimeSpan.MaxValue。 + + + + Server '{0}' sent back a fault indicating it is in the process of shutting down. Please see the inner exception for fault details. + 服务器“{0}”发回错误,指示其正在关机。有关错误的详细信息,请参见内部异常。 + + + + Server '{0}' sent back a fault indicating it is too busy to process the request. Please retry later. Please see the inner exception for fault details. + 服务器“{0}”发回错误,指示其太忙,无法处理请求。请稍后重试。有关错误的详细信息,请参见内部异常。 + + + + The socket was aborted because an asynchronous receive from the socket did not complete within the allotted timeout of {0}. The time allotted to this operation may have been a portion of a longer timeout. + 套接字已中止,因为来自套接字的异步接收在分配的超时 {0} 内未完成。分配给此操作的时间可能比超时长。 + + + + The socket connection was aborted because an asynchronous send to the socket did not complete within the allotted timeout of {0}. The time allotted to this operation may have been a portion of a longer timeout. + 套接字连接已中止,因为到套接字的异步发送未在分配的超时 {0} 内完成。分配给此操作的时间可能比超时长。 + + + + A graceful close was attempted on the socket, but the other side ({0}) is still sending data. + 已尝试正常关闭套接字,但另一端({0})仍在发送数据。 + + + + The remote endpoint of the socket ({0}) did not respond to a close request within the allotted timeout ({1}). It is likely that the remote endpoint is not calling Close after receiving the EOF signal (null) from Receive. The time allotted to this operation may have been a portion of a longer timeout. + 套接字({0})的远程终结点未在分配的超时({1})内响应关闭请求。可能远程终结点在从 Receive 接收 EOF 信号(Null)后未调用 Close。分配给此操作的时间可能比超时长。 + + + + The socket connection has been disposed. + 套接字连接已释放。 + + + + Transfer mode {0} is not supported by {1}. + {1} 不支持传输模式 {0}。 + + + + Could not connect to {0}. UDS error code {1}: {2}. + Could not connect to {0}. UDS error code {1}: {2}. + + + + Could not connect to {0}. The connection attempt lasted for a time span of {3}. UDS error code {1}: {2}. + Could not connect to {0}. The connection attempt lasted for a time span of {3}. UDS error code {1}: {2}. + + + + Insufficient winsock resources available to complete socket connection initiation. + Insufficient winsock resources available to complete socket connection initiation. + + + + Connecting to via {0} timed out after {1}. Connection attempts were made to {2} of {3} available addresses ({4}). Check the RemoteAddress of your channel and verify that the DNS records for this endpoint correspond to valid IP Addresses. The time allotted to this operation may have been a portion of a longer timeout. + Connecting to via {0} timed out after {1}. Connection attempts were made to {2} of {3} available addresses ({4}). Check the RemoteAddress of your channel and verify that the DNS records for this endpoint correspond to valid IP Addresses. The time allotted to this operation may have been a portion of a longer timeout. + + + + The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '{0}'. + The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '{0}'. + + + + The socket transfer timed out after {0}. You have exceeded the timeout set on your binding. The time allotted to this operation may have been a portion of a longer timeout. + The socket transfer timed out after {0}. You have exceeded the timeout set on your binding. The time allotted to this operation may have been a portion of a longer timeout. + + + + The socket connection was aborted by your local machine. This could be caused by a channel Abort(), or a transmission error from another thread using this socket. + The socket connection was aborted by your local machine. This could be caused by a channel Abort(), or a transmission error from another thread using this socket. + + + + A UDS error ({0}: {1}) occurred while transmitting data. + A UDS error ({0}: {1}) occurred while transmitting data. + + + + Cannot resolve the host name of URI "{0}" using DNS. + 无法使用 DNS 解析 URI“{0}”的主机名。 + + + + The protection level '{0}' was specified, yet SSL transport security only supports EncryptAndSign. + 指定了保护级别“{0}”,但 SSL 传输安全性仅支持 EncryptAndSign。 + + + + The value of this argument must be non-negative. + 此参数的值必须为非负。 + + + + The value of this argument must be positive. + 此参数的值必须为正。 + + + + + \ No newline at end of file diff --git a/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.zh-Hant.xlf b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.zh-Hant.xlf new file mode 100644 index 00000000000..d0eb2f2b4be --- /dev/null +++ b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.zh-Hant.xlf @@ -0,0 +1,152 @@ + + + + + + Process action '{0}'. + 處理動作 '{0}'。 + + + + The specified channel type {0} is not supported by this channel manager. + 此通道管理員不支援指定的通道類型 {0}。 + + + + ClientCredentialType.None is not valid for the TransportWithMessageCredential security mode. Specify a message credential type or use a different security mode. + ClientCredentialType.None 對於 TransportWithMessageCredential 安全性模式無效。請指定訊息認證類型,或使用不同的安全性模式。 + + + + No DNS entries exist for host {0}. + 沒有主機 {0} 的 DNS 項目。 + + + + Extended protection is not supported on this platform. Please install the appropriate patch or change the ExtendedProtectionPolicy on the Binding or BindingElement to a value with a PolicyEnforcement value of "Never" or "WhenSupported". + 這個平台不支援延伸的保護。請安裝適當的修補程式,或者將 Binding 或 BindingElement 上的 ExtendedProtectionPolicy 值變更為 "Never" 或 "WhenSupported" 的 PolicyEnforcement 值。 + + + + Insufficient memory avaliable to complete the operation. + 記憶體不足,無法完成作業。 + + + + No IPEndpoints were found for host {0}. + 找不到主機 {0} 的 IPEndpoints。 + + + + Timeout must be greater than or equal to TimeSpan.Zero. To disable timeout, specify TimeSpan.MaxValue. + Timeout 必須大於或等於 TimeSpan.Zero。若要停用逾時,請指定 TimeSpan.MaxValue。 + + + + Timeouts larger than Int32.MaxValue TotalMilliseconds (approximately 24 days) cannot be honored. To disable timeout, specify TimeSpan.MaxValue. + 無法遵循大於 Int32.MaxValue TotalMilliseconds (大約等於 24 天) 的逾時。若要停用逾時,請指定 TimeSpan.MaxValue。 + + + + Server '{0}' sent back a fault indicating it is in the process of shutting down. Please see the inner exception for fault details. + 伺服器 '{0}' 傳回錯誤,指出正在進行關機。如需錯誤詳細資訊,請參閱內部例外狀況。 + + + + Server '{0}' sent back a fault indicating it is too busy to process the request. Please retry later. Please see the inner exception for fault details. + 伺服器 '{0}' 傳回錯誤,指出因過於忙碌,無法處理要求。請稍後重試。請參考內部例外狀況,以取得錯誤詳細資料。 + + + + The socket was aborted because an asynchronous receive from the socket did not complete within the allotted timeout of {0}. The time allotted to this operation may have been a portion of a longer timeout. + 通訊端中止,因為來自通訊端的非同步接收未在分配的逾時 {0} 內完成。分配給此作業的時間可能是較長逾時的一部分。 + + + + The socket connection was aborted because an asynchronous send to the socket did not complete within the allotted timeout of {0}. The time allotted to this operation may have been a portion of a longer timeout. + 通訊端連線中止,因為目標為通訊端的非同步傳送未在分配的逾時 {0} 內完成。分配給此作業的時間可能是較長逾時的一部分。 + + + + A graceful close was attempted on the socket, but the other side ({0}) is still sending data. + 嘗試在通訊端上正常關閉,但另一端 ({0}) 仍在傳送資料。 + + + + The remote endpoint of the socket ({0}) did not respond to a close request within the allotted timeout ({1}). It is likely that the remote endpoint is not calling Close after receiving the EOF signal (null) from Receive. The time allotted to this operation may have been a portion of a longer timeout. + 通訊端的遠端端點 ({0}) 未在分配的逾時 ({1}) 內回應關閉要求。這有可能是因為遠端端點從 Receive 接收 EOF 信號 (Null) 之後未呼叫 Close。分配給此作業的時間可能是較長逾時的一部分。 + + + + The socket connection has been disposed. + 已處置通訊端連線。 + + + + Transfer mode {0} is not supported by {1}. + {1} 不支援傳輸模式 {0}。 + + + + Could not connect to {0}. UDS error code {1}: {2}. + Could not connect to {0}. UDS error code {1}: {2}. + + + + Could not connect to {0}. The connection attempt lasted for a time span of {3}. UDS error code {1}: {2}. + Could not connect to {0}. The connection attempt lasted for a time span of {3}. UDS error code {1}: {2}. + + + + Insufficient winsock resources available to complete socket connection initiation. + Insufficient winsock resources available to complete socket connection initiation. + + + + Connecting to via {0} timed out after {1}. Connection attempts were made to {2} of {3} available addresses ({4}). Check the RemoteAddress of your channel and verify that the DNS records for this endpoint correspond to valid IP Addresses. The time allotted to this operation may have been a portion of a longer timeout. + Connecting to via {0} timed out after {1}. Connection attempts were made to {2} of {3} available addresses ({4}). Check the RemoteAddress of your channel and verify that the DNS records for this endpoint correspond to valid IP Addresses. The time allotted to this operation may have been a portion of a longer timeout. + + + + The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '{0}'. + The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '{0}'. + + + + The socket transfer timed out after {0}. You have exceeded the timeout set on your binding. The time allotted to this operation may have been a portion of a longer timeout. + The socket transfer timed out after {0}. You have exceeded the timeout set on your binding. The time allotted to this operation may have been a portion of a longer timeout. + + + + The socket connection was aborted by your local machine. This could be caused by a channel Abort(), or a transmission error from another thread using this socket. + The socket connection was aborted by your local machine. This could be caused by a channel Abort(), or a transmission error from another thread using this socket. + + + + A UDS error ({0}: {1}) occurred while transmitting data. + A UDS error ({0}: {1}) occurred while transmitting data. + + + + Cannot resolve the host name of URI "{0}" using DNS. + 無法使用 DNS 解析 URI "{0}" 的主機名稱。 + + + + The protection level '{0}' was specified, yet SSL transport security only supports EncryptAndSign. + 已指定保護層級 '{0}',但是 SSL 傳輸安全性只支援 EncryptAndSign。 + + + + The value of this argument must be non-negative. + 此引數的值必須是非負數。 + + + + The value of this argument must be positive. + 此引數值必須是正數。 + + + + + \ No newline at end of file diff --git a/src/System.ServiceModel.UnixDomainSocket/src/System.ServiceModel.UnixDomainSocket.csproj b/src/System.ServiceModel.UnixDomainSocket/src/System.ServiceModel.UnixDomainSocket.csproj new file mode 100644 index 00000000000..3a0d87645aa --- /dev/null +++ b/src/System.ServiceModel.UnixDomainSocket/src/System.ServiceModel.UnixDomainSocket.csproj @@ -0,0 +1,43 @@ + + + $(WcfAssemblyVersion) + Microsoft + System.ServiceModel.UnixDomainSocket + true + true + $(NoWarn);NU5131 + net6.0 + $(Ship_WcfPackages) + Provides the types that permit SOAP messages to be exchanged using Unix domain socket. + + + + true + FxResources.$(AssemblyName).SR + false + System.SR + + + + + + true + Common\System\ServiceModel\%(RecursiveDir)%(Filename)%(Extension) + + + true + Common\System\IdentityModel\%(RecursiveDir)%(Filename)%(Extension) + + + true + Common\Internals\%(RecursiveDir)%(Filename)%(Extension) + + + Common\System\SR.cs + + + + + + + diff --git a/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/ChannelBindingUtility.cs b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/ChannelBindingUtility.cs new file mode 100644 index 00000000000..9adf7a18daa --- /dev/null +++ b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/ChannelBindingUtility.cs @@ -0,0 +1,13 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Security.Authentication.ExtendedProtection; + +namespace System.ServiceModel.Channels +{ + internal static class ChannelBindingUtility + { + private static readonly ExtendedProtectionPolicy s_disabledPolicy = new ExtendedProtectionPolicy(PolicyEnforcement.Never); + public static ExtendedProtectionPolicy DefaultPolicy { get; } = s_disabledPolicy; + } +} diff --git a/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/SocketAwaitableEventArgs.cs b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/SocketAwaitableEventArgs.cs new file mode 100644 index 00000000000..6c9e3644690 --- /dev/null +++ b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/SocketAwaitableEventArgs.cs @@ -0,0 +1,128 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Net.Sockets; +using System.Threading.Tasks.Sources; +using System.Threading; +using System.Threading.Tasks; +using System.Runtime.InteropServices; + +namespace System.ServiceModel.Channels +{ + // Copied and modified from https://github.com/dotnet/aspnetcore/blob/7a5d1cc1beda12eebb3fb3aa8ccb8253cf445115/src/Servers/Kestrel/Transport.Sockets/src/Internal/SocketAwaitableEventArgs.cs + + // A slimmed down version of https://github.com/dotnet/runtime/blob/82ca681cbac89d813a3ce397e0c665e6c051ed67/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.Tasks.cs#L798 that + // 1. Doesn't support any custom scheduling other than the PipeScheduler (no sync context, no task scheduler) + // 2. Doesn't do ValueTask validation using the token + // 3. Doesn't support usage outside of async/await (doesn't try to capture and restore the execution context) + // 4. Doesn't use cancellation tokens + internal class SocketAwaitableEventArgs : SocketAsyncEventArgs, IValueTaskSource, IValueTaskSource + { + private static readonly Action _continuationCompleted = _ => { }; + + private Action _continuation; + + public SocketAwaitableEventArgs() : base(unsafeSuppressExecutionContextFlow: true) { } + + public ValueTask ReceiveAsync(Socket socket, Memory buffer) + { + SetBuffer(buffer); + + if (socket.ReceiveAsync(this)) + { + return new ValueTask(this, 0); + } + + var bytesTransferred = BytesTransferred; + var error = SocketError; + + return error == SocketError.Success + ? new ValueTask(bytesTransferred) + : new ValueTask(Task.FromException(CreateException(error))); + } + + public ValueTask SendAsync(Socket socket, ReadOnlyMemory memory) + { + SetBuffer(MemoryMarshal.AsMemory(memory)); + + if (socket.SendAsync(this)) + { + return new ValueTask(this, 0); + } + + var bytesTransferred = BytesTransferred; + var error = SocketError; + + return error == SocketError.Success + ? ValueTask.CompletedTask + : new ValueTask(Task.FromException(CreateException(error))); + } + + protected override void OnCompleted(SocketAsyncEventArgs _) + { + var c = _continuation; + + if (c != null || (c = Interlocked.CompareExchange(ref _continuation, _continuationCompleted, null)) != null) + { + var continuationState = UserToken; + UserToken = null; + _continuation = _continuationCompleted; // in case someone's polling IsCompleted + + c.Invoke(continuationState); + } + } + + int IValueTaskSource.GetResult(short token) + { + _continuation = null; + + if (SocketError != SocketError.Success) + { + throw CreateException(SocketError); + } + + return BytesTransferred; + } + + void IValueTaskSource.GetResult(short token) + { + _continuation = null; + + if (SocketError != SocketError.Success) + { + throw CreateException(SocketError); + } + } + + protected static SocketException CreateException(SocketError e) + { + return new SocketException((int)e); + } + + public ValueTaskSourceStatus GetStatus(short token) + { + return !ReferenceEquals(_continuation, _continuationCompleted) ? ValueTaskSourceStatus.Pending : + SocketError == SocketError.Success ? ValueTaskSourceStatus.Succeeded : + ValueTaskSourceStatus.Faulted; + } + + public void OnCompleted(Action continuation, object state, short token, ValueTaskSourceOnCompletedFlags flags) + { + UserToken = state; + var prevContinuation = Interlocked.CompareExchange(ref _continuation, continuation, null); + if (ReferenceEquals(prevContinuation, _continuationCompleted)) + { + UserToken = null; + // This should only get hit if the operation completes between ValueTask.IsCompleted being + // called and returning false and this method being called. In which case we will have one extra frame + // on the call stack. This will only be a problem is calling ReceiveAsync in a loop. The only time Receive + // will be called in a loop we are doing so because the message size is larger than the max buffer size, + // which would mean we're receiving a very large message and the receive will be completing asynchronously. + // We read the message size from the NetTcp frame header and try allocate a buffer large enough for entire + // message. We then call ReceiveAsync with a buffer size up to the max buffer size. + continuation(state); + //ThreadPool.UnsafeQueueUserWorkItem(continuation, state, preferLocal: true); + } + } + } +} diff --git a/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/SocketConnection.cs b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/SocketConnection.cs new file mode 100644 index 00000000000..7f4097c7a3a --- /dev/null +++ b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/SocketConnection.cs @@ -0,0 +1,870 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Net.Sockets; +using System.Net; +using System.Runtime; +using System.Text; +using System.Threading.Tasks; +using System.Diagnostics; +using System.Threading; +using System.Runtime.InteropServices; +using System.Drawing; + +namespace System.ServiceModel.Channels +{ + internal class SocketConnection : IConnection + { + //// common state + private Socket _socket; + private TimeSpan _asyncSendTimeout; + private TimeSpan _readFinTimeout; + private TimeSpan _asyncReceiveTimeout; + private CloseState _closeState; + private bool _isShutdown; + private bool _aborted; + + //// close state + private TimeoutHelper _closeTimeoutHelper; + //private static Action s_onWaitForFinComplete = new Action(OnWaitForFinComplete); + + //// read state + //private int _asyncReadSize; + private SocketAwaitableEventArgs _asyncReadEventArgs; + private bool _asyncReadPending; + + //// write state + private SocketAwaitableEventArgs _asyncWriteEventArgs; + private bool _asyncWritePending; + + private Timer _receiveTimer; + private bool _receiveTimerEnabled; + private DateTime _lastReceiveTimeoutDeadline; + private static TimerCallback s_onReceiveTimeout = OnReceiveTimeout; + private Timer _sendTimer; + private bool _sendTimerEnabled; + private DateTime _lastSendTimeoutDeadline; + private static TimerCallback s_onSendTimeout = OnSendTimeout; + private string _timeoutErrorString; + private TransferOperation _timeoutErrorTransferOperation; + private UnixDomainSocketEndPoint _remoteEndpoint; + //private ConnectionBufferPool _connectionBufferPool; + private string _remoteEndpointAddress; + + public SocketConnection(Socket socket, int bufferSize) + { + _socket = socket ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(socket)); + ConnectionBufferSize = bufferSize; + _closeState = CloseState.Open; + _socket.SendBufferSize = _socket.ReceiveBufferSize = bufferSize; + _sendTimer = CreateTimer(s_onSendTimeout); + _receiveTimer = CreateTimer(s_onReceiveTimeout); + _asyncReadEventArgs = new SocketAwaitableEventArgs(); + _asyncWriteEventArgs = new SocketAwaitableEventArgs(); + _remoteEndpoint = null; + } + + private object ThisLock => this; + + public int ConnectionBufferSize { get; } + + public void Abort() + { + Abort(null, TransferOperation.Undefined); + } + + private void Abort(string timeoutErrorString, TransferOperation transferOperation) + { + // we could be timing out a cached connection + Abort(TraceEventType.Warning, timeoutErrorString, transferOperation); + } + + private void Abort(TraceEventType traceEventType, string timeoutErrorString, TransferOperation transferOperation) + { + lock (ThisLock) + { + if (_closeState == CloseState.Closed) + { + return; + } + + _timeoutErrorString = timeoutErrorString; + _timeoutErrorTransferOperation = transferOperation; + _aborted = true; + _closeState = CloseState.Closed; + + if (_asyncReadPending) + { + CancelReceiveTimer(); + } + else + { + DisposeReadEventArgs(); + } + + if (_asyncWritePending) + { + CancelSendTimer(); + } + else + { + DisposeWriteEventArgs(); + } + } + + _socket.Close(0); + } + + private void AbortRead() + { + lock (ThisLock) + { + if (_asyncReadPending) + { + if (_closeState != CloseState.Closed) + { + _asyncReadPending = false; + CancelReceiveTimer(dispose: true); + } + else + { + DisposeReadEventArgs(); + } + } + } + } + + private void AbortWrite() + { + lock (ThisLock) + { + if (_asyncWritePending) + { + if (_closeState != CloseState.Closed) + { + _asyncWritePending = false; + CancelSendTimer(dispose: true); + } + else + { + DisposeWriteEventArgs(); + } + } + } + } + + public ValueTask ReadAsync(Memory buffer, TimeSpan timeout) + { + if (buffer.Length <= 0) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(buffer.Length), buffer.Length, SR.ValueMustBePositive)); + } + ThrowIfNotOpen(); + + return ReadCoreAsync(buffer, timeout, false); + } + + private async ValueTask ReadCoreAsync(Memory buffer, TimeSpan timeout, bool closing) + { + int bytesRead = 0; + TimeoutHelper timeoutHelper = new TimeoutHelper(timeout); + bool abortRead = true; + + lock (ThisLock) + { + _asyncReadPending = true; + SetReadTimeout(timeout, closing); + } + + bool restoreFlow = false; + try + { + if (!ExecutionContext.IsFlowSuppressed()) + { + ExecutionContext.SuppressFlow(); + restoreFlow = true; + } + + var resultTask = _asyncReadEventArgs.ReceiveAsync(_socket, buffer); + if (restoreFlow) + { + restoreFlow = false; + ExecutionContext.RestoreFlow(); + } + bytesRead = await resultTask; + abortRead = false; + if (WcfEventSource.Instance.SocketReadStopIsEnabled()) + { + WcfEventSource.Instance.SocketAsyncReadStop((_socket != null) ? _socket.GetHashCode() : -1, bytesRead, this.RemoteEndpointAddress); + } + } + catch (SocketException socketException) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( + ConvertReceiveException(socketException, timeoutHelper.RemainingTime(), timeout)); + } + catch (ObjectDisposedException objectDisposedException) + { + Exception exceptionToThrow = ConvertObjectDisposedException(objectDisposedException, TransferOperation.Read); + if (ReferenceEquals(exceptionToThrow, objectDisposedException)) + throw; + else + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(exceptionToThrow); + } + finally + { + CancelReceiveTimer(); + // Restore the current ExecutionContext + if (restoreFlow) + ExecutionContext.RestoreFlow(); + + if (abortRead) + { + AbortRead(); + } + } + + lock (ThisLock) + { + _asyncReadPending = false; + if (_closeState == CloseState.Closed) + { + DisposeReadEventArgs(); + } + } + + return bytesRead; + } + + public async ValueTask WriteAsync(ReadOnlyMemory buffer, bool immediate, TimeSpan timeout) + { + if (buffer.Length <= 0) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(buffer.Length), buffer.Length, SR.ValueMustBePositive)); + } + bool abortWrite = true; + + if (WcfEventSource.Instance.SocketAsyncWriteStartIsEnabled()) + { + WcfEventSource.Instance.SocketAsyncWriteStart(_socket.GetHashCode(), buffer.Length, RemoteEndpointAddress); + } + + lock (ThisLock) + { + Fx.Assert(!_asyncWritePending, "Called BeginWrite twice."); + ThrowIfClosed(); + SetWriteTimeout(timeout); + _asyncWritePending = true; + } + + TimeoutHelper timeoutHelper = new TimeoutHelper(timeout); + bool restoreFlow = false; + try + { + if (!ExecutionContext.IsFlowSuppressed()) + { + ExecutionContext.SuppressFlow(); + restoreFlow = true; + } + + var resultTask = _asyncWriteEventArgs.SendAsync(_socket, buffer); + if (restoreFlow) + { + restoreFlow = false; + ExecutionContext.RestoreFlow(); + } + + await resultTask; + abortWrite = false; + } + catch (SocketException socketException) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( + ConvertSendException(socketException, timeoutHelper.RemainingTime(), timeout)); + } + catch (ObjectDisposedException objectDisposedException) + { + Exception exceptionToThrow = ConvertObjectDisposedException(objectDisposedException, TransferOperation.Write); + if (ReferenceEquals(exceptionToThrow, objectDisposedException)) + { + throw; + } + else + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(exceptionToThrow); + } + } + finally + { + _asyncWritePending = false; + CancelSendTimer(); + // Restore the current ExecutionContext + if (restoreFlow) + ExecutionContext.RestoreFlow(); + + if (abortWrite) + { + AbortWrite(); + } + } + } + + public async ValueTask CloseAsync(TimeSpan timeout) + { + lock (ThisLock) + { + if (_closeState == CloseState.Closing || _closeState == CloseState.Closed) + { + // already closing or closed, so just return + return; + } + + _closeState = CloseState.Closing; + } + + // first we shutdown our send-side + _closeTimeoutHelper = new TimeoutHelper(timeout); + Shutdown(_closeTimeoutHelper.RemainingTime()); + _readFinTimeout = _closeTimeoutHelper.RemainingTime(); + + try + { + // A FIN (shutdown) packet has already been sent to the remote host and we're waiting for the remote + // host to send a FIN back. A pending read on a socket will complete returning zero bytes when a FIN + // packet is received. + byte[] dummy = Fx.AllocateByteArray(1); + int bytesRead = await ReadCoreAsync(dummy, _readFinTimeout, true); + + if (bytesRead > 0) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( + new CommunicationException(SR.Format(SR.SocketCloseReadReceivedData, _socket.RemoteEndPoint))); + } + } + catch (TimeoutException timeoutException) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new TimeoutException( + SR.Format(SR.SocketCloseReadTimeout, _socket.RemoteEndPoint, _readFinTimeout), timeoutException)); + } + + _socket.Close(TimeoutHelper.ToMilliseconds(_closeTimeoutHelper.RemainingTime())); + + lock (ThisLock) + { + // Abort could have been called on a separate thread and cleaned up + // our buffers/completion here + if (_closeState != CloseState.Closed) + { + if (!_asyncReadPending) + { + DisposeReadEventArgs(); + } + + if (!_asyncWritePending) + { + DisposeWriteEventArgs(); + } + } + + _closeState = CloseState.Closed; + } + } + + private void Shutdown(TimeSpan timeout) + { + lock (ThisLock) + { + if (_isShutdown) + { + return; + } + + _isShutdown = true; + } + + try + { + _socket.Shutdown(SocketShutdown.Send); + } + catch (SocketException socketException) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( + ConvertSendException(socketException, TimeSpan.MaxValue, _asyncSendTimeout)); + } + catch (ObjectDisposedException objectDisposedException) + { + Exception exceptionToThrow = ConvertObjectDisposedException(objectDisposedException, TransferOperation.Undefined); + if (ReferenceEquals(exceptionToThrow, objectDisposedException)) + { + throw; + } + else + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(exceptionToThrow); + } + } + } + + private string RemoteEndpointAddress + { + get + { + if (_remoteEndpointAddress == null) + { + try + { + if (TryGetEndpoints(out UnixDomainSocketEndPoint remote)) + { + _remoteEndpointAddress = remote.ToString(); + } + else + { + //null indicates not initialized. + _remoteEndpointAddress = string.Empty; + } + } + catch (Exception exception) + { + if (Fx.IsFatal(exception)) + { + throw; + } + + } + } + return _remoteEndpointAddress; + } + } + + private bool TryGetEndpoints(out UnixDomainSocketEndPoint remoteIPEndpoint) + { + remoteIPEndpoint = null; + + if (_closeState == CloseState.Open) + { + try + { + remoteIPEndpoint = _remoteEndpoint ?? (UnixDomainSocketEndPoint)_socket.RemoteEndPoint; + } + catch (Exception exception) + { + if (Fx.IsFatal(exception)) + { + throw; + } + } + } + + return remoteIPEndpoint != null; + } + + // This method should be called inside ThisLock + private void DisposeReadEventArgs() + { + _asyncReadEventArgs.Dispose(); + } + + // This method should be called inside ThisLock + private void DisposeWriteEventArgs() + { + _asyncWriteEventArgs.Dispose(); + } + + private void ThrowIfNotOpen() + { + if (_closeState == CloseState.Closing || _closeState == CloseState.Closed) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( + ConvertObjectDisposedException(new ObjectDisposedException( + GetType().ToString(), SR.SocketConnectionDisposed), TransferOperation.Undefined)); + } + } + + private void ThrowIfClosed() + { + if (_closeState == CloseState.Closed) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( + ConvertObjectDisposedException(new ObjectDisposedException( + GetType().ToString(), SR.SocketConnectionDisposed), TransferOperation.Undefined)); + } + } + + private void SetReadTimeout(TimeSpan timeout, bool closing) + { + if (timeout <= TimeSpan.Zero) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( + new TimeoutException(SR.Format(SR.UDSConnectionTimedOut, timeout))); + } + + _asyncReceiveTimeout = timeout; + if (timeout == TimeSpan.MaxValue) + { + CancelReceiveTimer(); + } + else + { + if (ShouldUpdateTimeout(_lastReceiveTimeoutDeadline, timeout)) + { + lock (ThisLock) + { + if (!closing || _closeState != CloseState.Closing) + { + ThrowIfNotOpen(); + } + _lastReceiveTimeoutDeadline = DateTime.UtcNow + timeout; + _receiveTimer.Change(timeout, Timeout.InfiniteTimeSpan); + } + } + + _receiveTimerEnabled = true; + } + } + + private void CancelReceiveTimer(bool dispose = false) + { + // Don't change the timer as modifing the Timer is expensive. It's most likely going to be set + // to another future time before it actually fires. By using a bool to make the fired timer a + // no-op we only modify the Timer, if at all. Multiple receives are often part of a single + // compound operation with the same ultimate final timeout deadline. This means multiple calls + // to ReceiveAsync will have the same deadline and we can avoid modifying the timer by not + // changing it when a receive completes and just making it a no-op. + if (_receiveTimerEnabled) + { + _receiveTimerEnabled = false; + } + + if (dispose) + { + _receiveTimer.Dispose(); + } + } + + private void SetWriteTimeout(TimeSpan timeout) + { + if (timeout <= TimeSpan.Zero) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( + new TimeoutException(SR.Format(SR.UDSConnectionTimedOut, timeout))); + } + + _asyncSendTimeout = timeout; + if (timeout == TimeSpan.MaxValue) + { + CancelSendTimer(); + } + else + { + if (ShouldUpdateTimeout(_lastSendTimeoutDeadline, timeout)) + { + lock (ThisLock) + { + ThrowIfNotOpen(); + _lastSendTimeoutDeadline = DateTime.UtcNow + timeout; + _sendTimer.Change(timeout, Timeout.InfiniteTimeSpan); + } + } + + _sendTimerEnabled = true; + } + } + + private void CancelSendTimer(bool dispose = false) + { + // See CancelReceiveTimer for rationale of not cancelling the underlying timer. + if (_sendTimerEnabled) + { + _sendTimerEnabled = false; + } + + if (dispose) + { + _sendTimer.Dispose(); + } + } + + private bool ShouldUpdateTimeout(DateTime oldTimeoutDeadline, TimeSpan newTimeout) + { + var oldTimeout = oldTimeoutDeadline - DateTime.UtcNow; + if (oldTimeout < TimeSpan.Zero) // Expired already + return true; + + long threshold = oldTimeout.Ticks >> 4; // >> 4 is the same as / 16. Are the timeouts within 6.25% of each other + long delta = oldTimeout.Ticks > newTimeout.Ticks ? oldTimeout.Ticks - newTimeout.Ticks : newTimeout.Ticks - oldTimeout.Ticks; + + return delta > threshold; + } + + private static void OnReceiveTimeout(object state) + { + SocketConnection thisPtr = (SocketConnection)state; + if (thisPtr._receiveTimerEnabled) + { + thisPtr.Abort(SR.Format(SR.SocketAbortedReceiveTimedOut, thisPtr._asyncReceiveTimeout), TransferOperation.Read); + } + } + + private static void OnSendTimeout(object state) + { + SocketConnection thisPtr = (SocketConnection)state; + if (thisPtr._sendTimerEnabled) + { + thisPtr.Abort(TraceEventType.Warning, SR.Format(SR.SocketAbortedSendTimedOut, thisPtr._asyncSendTimeout), TransferOperation.Write); + } + } + + private Exception ConvertObjectDisposedException(ObjectDisposedException originalException, TransferOperation transferOperation) + { + if (_timeoutErrorString != null) + { + return ConvertTimeoutErrorException(originalException, transferOperation, _timeoutErrorString, _timeoutErrorTransferOperation); + } + else if (_aborted) + { + return new CommunicationObjectAbortedException(SR.SocketConnectionDisposed, originalException); + } + else + { + return originalException; + } + } + + private Exception ConvertSendException(SocketException socketException, TimeSpan remainingTime, TimeSpan timeout) + { + return ConvertTransferException(socketException, timeout, socketException, + TransferOperation.Write, _aborted, _timeoutErrorString, _timeoutErrorTransferOperation, this, remainingTime); + } + + private Exception ConvertReceiveException(SocketException socketException, TimeSpan remainingTime, TimeSpan timeout) + { + return ConvertTransferException(socketException, timeout, socketException, + TransferOperation.Read, _aborted, _timeoutErrorString, _timeoutErrorTransferOperation, this, remainingTime); + } + + private static Exception ConvertTransferException(SocketException socketException, TimeSpan timeout, Exception originalException, + TransferOperation transferOperation, bool aborted, string timeoutErrorString, TransferOperation timeoutErrorTransferOperation, + SocketConnection socketConnection, TimeSpan remainingTime) + { + if (socketException.ErrorCode == UnsafeNativeMethods.ERROR_INVALID_HANDLE) + { + return new CommunicationObjectAbortedException(socketException.Message, socketException); + } + + if (timeoutErrorString != null) + { + return ConvertTimeoutErrorException(originalException, transferOperation, timeoutErrorString, timeoutErrorTransferOperation); + } + + // 10053 can occur due to our timeout sockopt firing, so map to TimeoutException in that case + if (socketException.ErrorCode == UnsafeNativeMethods.WSAECONNABORTED && + remainingTime <= TimeSpan.Zero) + { + TimeoutException timeoutException = new TimeoutException(SR.Format(SR.UDSConnectionTimedOut, timeout), originalException); + return timeoutException; + } + + if (socketException.ErrorCode == UnsafeNativeMethods.WSAENETRESET || + socketException.ErrorCode == UnsafeNativeMethods.WSAECONNABORTED || + socketException.ErrorCode == UnsafeNativeMethods.WSAECONNRESET) + { + if (aborted) + { + return new CommunicationObjectAbortedException(SR.UDSLocalConnectionAborted, originalException); + } + else + { + CommunicationException communicationException = new CommunicationException(SR.Format(SR.UDSConnectionResetError, timeout), originalException); + return communicationException; + } + } + else if (socketException.ErrorCode == UnsafeNativeMethods.WSAETIMEDOUT) + { + TimeoutException timeoutException = new TimeoutException(SR.Format(SR.UDSConnectionTimedOut, timeout), originalException); + return timeoutException; + } + else + { + if (aborted) + { + return new CommunicationObjectAbortedException(SR.Format(SR.UDSTransferError, socketException.ErrorCode, socketException.Message), originalException); + } + else + { + CommunicationException communicationException = new CommunicationException(SR.Format(SR.UDSTransferError, socketException.ErrorCode, socketException.Message), originalException); + return communicationException; + } + } + } + + private static Exception ConvertTimeoutErrorException(Exception originalException, + TransferOperation transferOperation, string timeoutErrorString, TransferOperation timeoutErrorTransferOperation) + { + if (timeoutErrorString == null) + { + Fx.Assert("Argument timeoutErrorString must not be null."); + } + + if (transferOperation == timeoutErrorTransferOperation) + { + return new TimeoutException(timeoutErrorString, originalException); + } + else + { + return new CommunicationException(timeoutErrorString, originalException); + } + } + + // Avoid rooting any values stored in asynclocals. + private Timer CreateTimer(TimerCallback callback) + { + if (callback == null) + { + throw new ArgumentNullException(nameof(callback)); + } + + // Don't capture the current ExecutionContext and its AsyncLocals onto the timer + bool restoreFlow = false; + try + { + if (!ExecutionContext.IsFlowSuppressed()) + { + ExecutionContext.SuppressFlow(); + restoreFlow = true; + } + + return new Timer(callback, this, Timeout.Infinite, Timeout.Infinite); + } + finally + { + // Restore the current ExecutionContext + if (restoreFlow) + { + ExecutionContext.RestoreFlow(); + } + } + } + + private enum CloseState + { + Open, + Closing, + Closed, + } + + private enum TransferOperation + { + Write, + Read, + Undefined, + } + } + + internal class SocketConnectionInitiator : IConnectionInitiator + { + private int _bufferSize; + + public SocketConnectionInitiator(int bufferSize) + { + _bufferSize = bufferSize; + } + + private async Task CreateConnectionAsync(Uri uriPath) + { + Socket socket = null; + try + { + AddressFamily addressFamily = AddressFamily.Unix; + socket = new Socket(addressFamily, SocketType.Stream, ProtocolType.IP); + var endpoint = new UnixDomainSocketEndPoint(uriPath.LocalPath); + await socket.ConnectAsync(endpoint); + return new SocketConnection(socket, _bufferSize); + } + catch + { + socket.Dispose(); + throw; + } + } + + public static Exception ConvertConnectException(SocketException socketException, Uri remoteUri, TimeSpan timeSpent, Exception innerException) + { + if ((int)socketException.SocketErrorCode == UnsafeNativeMethods.ERROR_INVALID_HANDLE) + { + return new CommunicationObjectAbortedException(socketException.Message, socketException); + } + + if ((int)socketException.SocketErrorCode == UnsafeNativeMethods.WSAEADDRNOTAVAIL || + (int)socketException.SocketErrorCode == UnsafeNativeMethods.WSAECONNREFUSED || + (int)socketException.SocketErrorCode == UnsafeNativeMethods.WSAENETDOWN || + (int)socketException.SocketErrorCode == UnsafeNativeMethods.WSAENETUNREACH || + (int)socketException.SocketErrorCode == UnsafeNativeMethods.WSAEHOSTDOWN || + (int)socketException.SocketErrorCode == UnsafeNativeMethods.WSAEHOSTUNREACH || + (int)socketException.SocketErrorCode == UnsafeNativeMethods.WSAETIMEDOUT) + { + if (timeSpent == TimeSpan.MaxValue) + { + return new EndpointNotFoundException(SR.Format(SR.UDSConnectError, remoteUri.AbsoluteUri, (int)socketException.SocketErrorCode, socketException.Message), innerException); + } + else + { + return new EndpointNotFoundException(SR.Format(SR.UDSConnectErrorWithTimeSpan, remoteUri.AbsoluteUri, (int)socketException.SocketErrorCode, socketException.Message, timeSpent), innerException); + } + } + else if ((int)socketException.SocketErrorCode == UnsafeNativeMethods.WSAENOBUFS) + { + return new InsufficientMemoryException(SR.UDSConnectNoBufs, innerException); + } + else if ((int)socketException.SocketErrorCode == UnsafeNativeMethods.ERROR_NOT_ENOUGH_MEMORY || + (int)socketException.SocketErrorCode == UnsafeNativeMethods.ERROR_NO_SYSTEM_RESOURCES || + (int)socketException.SocketErrorCode == UnsafeNativeMethods.ERROR_OUTOFMEMORY) + { + return new InsufficientMemoryException(SR.InsufficentMemory, socketException); + } + else + { + if (timeSpent == TimeSpan.MaxValue) + { + return new CommunicationException(SR.Format(SR.UDSConnectError, remoteUri.AbsoluteUri, (int)socketException.SocketErrorCode, socketException.Message), innerException); + } + else + { + return new CommunicationException(SR.Format(SR.UDSConnectErrorWithTimeSpan, remoteUri.AbsoluteUri, (int)socketException.SocketErrorCode, socketException.Message, timeSpent), innerException); + } + } + } + + private static TimeoutException CreateTimeoutException(Uri uri, TimeSpan timeout, SocketException innerException) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new TimeoutException("Timed out while connecting to Unix domain socket", innerException)); + } + + public async ValueTask ConnectAsync(Uri uri, TimeSpan timeout) + { + IConnection socketConnection = null; + SocketException lastException = null; + TimeoutHelper timeoutHelper = new TimeoutHelper(timeout); + + if (timeoutHelper.RemainingTime() == TimeSpan.Zero) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( + CreateTimeoutException(uri, timeoutHelper.OriginalTimeout, lastException)); + } + + try + { + socketConnection = await CreateConnectionAsync(uri); + lastException = null; + } + catch (SocketException socketException) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( + SocketConnectionInitiator.ConvertConnectException(lastException, uri, + timeoutHelper.ElapsedTime(), socketException)); + } + + return socketConnection; + } + } + +} diff --git a/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/SslProtocolsHelper.cs b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/SslProtocolsHelper.cs new file mode 100644 index 00000000000..1df9870f085 --- /dev/null +++ b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/SslProtocolsHelper.cs @@ -0,0 +1,30 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.ComponentModel; +using System.Security.Authentication; + +namespace System.ServiceModel.Channels +{ + internal static class SslProtocolsHelper + { + internal static bool IsDefined(SslProtocols value) + { + SslProtocols allValues = SslProtocols.None; + foreach (var protocol in Enum.GetValues(typeof(SslProtocols))) + { + allValues |= (SslProtocols)protocol; + } + return (value & allValues) == value; + } + + internal static void Validate(SslProtocols value) + { + if (!IsDefined(value)) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidEnumArgumentException(nameof(value), (int)value, + typeof(SslProtocols))); + } + } + } +} diff --git a/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/TransportDefaults.cs b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/TransportDefaults.cs new file mode 100644 index 00000000000..5921bf547ce --- /dev/null +++ b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/TransportDefaults.cs @@ -0,0 +1,38 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Security; +using System.Security.Authentication; +using System.Security.Principal; +using System.Text; +using System.Threading.Tasks; +using SSAuth = System.Security.Authentication; + +namespace System.ServiceModel.Channels +{ + internal static class UnixDomainSocketTransportDefaults + { + public const long MaxReceivedMessageSize = 65536; + public const long MaxBufferPoolSize = 512 * 1024; + public const int MaxBufferSize = (int)MaxReceivedMessageSize; + public const SslProtocols SslProtocols = + // SSL3 is not supported in CoreFx. + SSAuth.SslProtocols.Tls | + SSAuth.SslProtocols.Tls11 | + SSAuth.SslProtocols.Tls12; + public static TimeSpan ConnectionLeaseTimeout => TimeSpan.FromMinutes(5); + public const bool PortSharingEnabled = false; + public const bool TeredoEnabled = false; + } + + internal static class ConnectionOrientedTransportDefaults + { + public const string ConnectionPoolGroupName = "default"; + public static TimeSpan IdleTimeout => TimeSpan.FromMinutes(2); + public const int MaxOutboundConnectionsPerEndpoint = 10; + public const TransferMode TransferMode = ServiceModel.TransferMode.Buffered; + } +} diff --git a/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/UnixDomainSocketChannelFactory.cs b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/UnixDomainSocketChannelFactory.cs new file mode 100644 index 00000000000..41f9651c864 --- /dev/null +++ b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/UnixDomainSocketChannelFactory.cs @@ -0,0 +1,135 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Globalization; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace System.ServiceModel.Channels +{ + internal sealed class UnixDomainSocketChannelFactory : NetFramingTransportChannelFactory, IConnectionPoolSettings + { + public UnixDomainSocketChannelFactory(UnixDomainSocketTransportBindingElement bindingElement, BindingContext context) + : base(bindingElement, context, + bindingElement.ConnectionPoolSettings.GroupName, + bindingElement.ConnectionPoolSettings.IdleTimeout, + bindingElement.ConnectionPoolSettings.MaxOutboundConnectionsPerEndpoint) + { + LeaseTimeout = bindingElement.ConnectionPoolSettings.LeaseTimeout; + } + + public TimeSpan LeaseTimeout { get; } + + public override string Scheme + { + get { return "net.uds"; } + } + + public override IConnectionInitiator GetConnectionInitiator() + { + return new SocketConnectionInitiator(ConnectionBufferSize); + } + + ///TODO Check with Matt + protected override string GetConnectionPoolKey(EndpointAddress address, Uri via) + { + return via.AbsolutePath; + } + + protected override TChannel OnCreateChannel(EndpointAddress address, Uri via) + { + if(address.Identity == null) + { + var hostIdentity = new DnsEndpointIdentity(address.Uri.Host ?? "localhost"); + var uriBuilder = new UriBuilder(address.Uri); + uriBuilder.Host = null; + address = new EndpointAddress(uriBuilder.Uri, hostIdentity,address.Headers.ToArray()); + } + + if(via !=null) + { + var uriBuilder = new UriBuilder(via); + uriBuilder.Host = null; + via = uriBuilder.Uri; + } + + return base.OnCreateChannel(address,via); + } + public override T GetProperty() + { + if (typeof(T) == typeof(IConnectionPoolSettings)) + { + return (T)(object)this; + } + + return base.GetProperty(); + } + + T IConnectionPoolSettings.GetConnectionPoolSetting(string settingName) + { + if (typeof(T) == typeof(TimeSpan)) + { + TimeSpan temp; + switch (settingName) + { + case nameof(LeaseTimeout): + temp = LeaseTimeout; + break; + case nameof(IdleTimeout): + temp = IdleTimeout; + break; + case nameof(MaxOutputDelay): + temp = MaxOutputDelay; + break; + default: + return default(T); + } + return Unsafe.As(ref temp); + } + + if (typeof(T) == typeof(int)) + { + int temp; + switch (settingName) + { + case nameof(ConnectionBufferSize): + temp = ConnectionBufferSize; + break; + case nameof(MaxOutboundConnectionsPerEndpoint): + temp = MaxOutboundConnectionsPerEndpoint; + break; + default: + return default(T); + } + return Unsafe.As(ref temp); + } + + if (typeof(T) == typeof(string)) + { + if (settingName == nameof(ConnectionPoolGroupName)) + return (T)(object)ConnectionPoolGroupName; + } + + return default(T); + } + + bool IConnectionPoolSettings.IsCompatible(IConnectionPoolSettings other) + { + // Other must be a TcpChannelFactory + if (other.GetType().IsConstructedGenericType) + { + if (other.GetType().GetGenericTypeDefinition() != typeof(UnixDomainSocketChannelFactory<>)) + { + return false; + } + } + + return (LeaseTimeout == other.GetConnectionPoolSetting(nameof(LeaseTimeout))) && + (ConnectionPoolGroupName == other.GetConnectionPoolSetting(nameof(ConnectionPoolGroupName))) && + (ConnectionBufferSize == other.GetConnectionPoolSetting(nameof(ConnectionBufferSize))) && + (MaxOutboundConnectionsPerEndpoint == other.GetConnectionPoolSetting(nameof(MaxOutboundConnectionsPerEndpoint))) && + (IdleTimeout == other.GetConnectionPoolSetting(nameof(IdleTimeout))) && + (MaxOutputDelay == other.GetConnectionPoolSetting(nameof(MaxOutputDelay))); + } + } +} diff --git a/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/UnixDomainSocketConnectionPoolSettings.cs b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/UnixDomainSocketConnectionPoolSettings.cs new file mode 100644 index 00000000000..67012da0162 --- /dev/null +++ b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/UnixDomainSocketConnectionPoolSettings.cs @@ -0,0 +1,127 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Runtime; + +namespace System.ServiceModel.Channels +{ + public sealed class UnixDomainSocketConnectionPoolSettings + { + private string _groupName; + private TimeSpan _idleTimeout; + private TimeSpan _leaseTimeout; + private int _maxOutboundConnectionsPerEndpoint; + + internal UnixDomainSocketConnectionPoolSettings() + { + _groupName = ConnectionOrientedTransportDefaults.ConnectionPoolGroupName; + _idleTimeout = ConnectionOrientedTransportDefaults.IdleTimeout; + _leaseTimeout = UnixDomainSocketTransportDefaults.ConnectionLeaseTimeout; + _maxOutboundConnectionsPerEndpoint = ConnectionOrientedTransportDefaults.MaxOutboundConnectionsPerEndpoint; + } + + internal UnixDomainSocketConnectionPoolSettings(UnixDomainSocketConnectionPoolSettings unixDomainSocketConnectionPoolSettings) + { + _groupName = unixDomainSocketConnectionPoolSettings._groupName; + _idleTimeout = unixDomainSocketConnectionPoolSettings._idleTimeout; + _leaseTimeout = unixDomainSocketConnectionPoolSettings._leaseTimeout; + _maxOutboundConnectionsPerEndpoint = unixDomainSocketConnectionPoolSettings._maxOutboundConnectionsPerEndpoint; + } + + public string GroupName + { + get { return _groupName; } + set + { + _groupName = value ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(value)); + } + } + + public TimeSpan IdleTimeout + { + get { return _idleTimeout; } + set + { + if (value < TimeSpan.Zero) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(value), value, + SR.SFxTimeoutOutOfRange0)); + } + + if (TimeoutHelper.IsTooLarge(value)) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(value), value, + SR.SFxTimeoutOutOfRangeTooBig)); + } + + _idleTimeout = value; + } + } + + public TimeSpan LeaseTimeout + { + get { return _leaseTimeout; } + set + { + if (value < TimeSpan.Zero) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(value), value, + SR.SFxTimeoutOutOfRange0)); + } + + if (TimeoutHelper.IsTooLarge(value)) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(value), value, + SR.SFxTimeoutOutOfRangeTooBig)); + } + + _leaseTimeout = value; + } + } + + public int MaxOutboundConnectionsPerEndpoint + { + get { return _maxOutboundConnectionsPerEndpoint; } + set + { + if (value < 0) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(value), value, + SR.ValueMustBeNonNegative)); + } + + _maxOutboundConnectionsPerEndpoint = value; + } + } + + internal UnixDomainSocketConnectionPoolSettings Clone() + { + return new UnixDomainSocketConnectionPoolSettings(this); + } + + internal bool IsMatch(UnixDomainSocketConnectionPoolSettings unixDomainSocketConnectionPoolSettings) + { + if (_groupName != unixDomainSocketConnectionPoolSettings._groupName) + { + return false; + } + + if (_idleTimeout != unixDomainSocketConnectionPoolSettings._idleTimeout) + { + return false; + } + + if (_leaseTimeout != unixDomainSocketConnectionPoolSettings._leaseTimeout) + { + return false; + } + + if (_maxOutboundConnectionsPerEndpoint != unixDomainSocketConnectionPoolSettings._maxOutboundConnectionsPerEndpoint) + { + return false; + } + + return true; + } + } +} diff --git a/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/UnixDomainSocketTransportBindingElement.cs b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/UnixDomainSocketTransportBindingElement.cs new file mode 100644 index 00000000000..dab104a7be4 --- /dev/null +++ b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/UnixDomainSocketTransportBindingElement.cs @@ -0,0 +1,114 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Security.Authentication.ExtendedProtection; + +namespace System.ServiceModel.Channels +{ + public class UnixDomainSocketTransportBindingElement : ConnectionOrientedTransportBindingElement + { + ExtendedProtectionPolicy _extendedProtectionPolicy; + + public UnixDomainSocketTransportBindingElement() + : base() + { + ConnectionPoolSettings = new UnixDomainSocketConnectionPoolSettings(); + _extendedProtectionPolicy = ChannelBindingUtility.DefaultPolicy; + } + + protected UnixDomainSocketTransportBindingElement(UnixDomainSocketTransportBindingElement elementToBeCloned) + : base(elementToBeCloned) + { + ConnectionPoolSettings = elementToBeCloned.ConnectionPoolSettings.Clone(); + _extendedProtectionPolicy = elementToBeCloned._extendedProtectionPolicy; + } + + public UnixDomainSocketConnectionPoolSettings ConnectionPoolSettings { get; } + + public override string Scheme => "net.uds"; + + public ExtendedProtectionPolicy ExtendedProtectionPolicy + { + get + { + return _extendedProtectionPolicy; + } + set + { + if (value == null) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(value)); + } + + if (value.PolicyEnforcement == PolicyEnforcement.Always && + !ExtendedProtectionPolicy.OSSupportsExtendedProtection) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( + new PlatformNotSupportedException(SR.ExtendedProtectionNotSupported)); + } + + _extendedProtectionPolicy = value; + } + } + + public override BindingElement Clone() + { + return new UnixDomainSocketTransportBindingElement(this); + } + + public override IChannelFactory BuildChannelFactory(BindingContext context) + { + if (context == null) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(context)); + } + + if (!CanBuildChannelFactory(context)) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("TChannel", SR.Format(SR.ChannelTypeNotSupported, typeof(TChannel))); + } + + return (IChannelFactory)(object)new UnixDomainSocketChannelFactory(this, context); + } + + public override T GetProperty(BindingContext context) + { + if (context == null) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(context)); + } + if (typeof(T) == typeof(IBindingDeliveryCapabilities)) + { + return (T)(object)new BindingDeliveryCapabilitiesHelper(); + } + else if (typeof(T) == typeof(ExtendedProtectionPolicy)) + { + return (T)(object)ExtendedProtectionPolicy; + } + else if (typeof(T) == typeof(ITransportCompressionSupport)) + { + return (T)(object)new TransportCompressionSupportHelper(); + } + else + { + return base.GetProperty(context); + } + } + + private class BindingDeliveryCapabilitiesHelper : IBindingDeliveryCapabilities + { + internal BindingDeliveryCapabilitiesHelper() + { + } + bool IBindingDeliveryCapabilities.AssuresOrderedDelivery => true; + + bool IBindingDeliveryCapabilities.QueuedDelivery => false; + } + + private class TransportCompressionSupportHelper : ITransportCompressionSupport + { + public bool IsCompressionFormatSupported(CompressionFormat compressionFormat) => true; + } + } +} + diff --git a/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/UnixPosixIdentityBindingElement.cs b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/UnixPosixIdentityBindingElement.cs new file mode 100644 index 00000000000..1984256ecd6 --- /dev/null +++ b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/UnixPosixIdentityBindingElement.cs @@ -0,0 +1,69 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.ComponentModel; +using System.Net.Security; +using System.ServiceModel.Security; + +namespace System.ServiceModel.Channels +{ + public class UnixPosixIdentityBindingElement : StreamUpgradeBindingElement + { + + public UnixPosixIdentityBindingElement() : base() + { + } + + protected UnixPosixIdentityBindingElement(UnixPosixIdentityBindingElement elementToBeCloned) : base(elementToBeCloned) + { + } + + public override BindingElement Clone() => new UnixPosixIdentityBindingElement(this); + + public override IChannelFactory BuildChannelFactory(BindingContext context) + { + if (context == null) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(context)); + } + + context.BindingParameters.Add(this); + return context.BuildInnerChannelFactory(); + } + + public override bool CanBuildChannelFactory(BindingContext context) + { + if (context == null) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(context)); + } + + context.BindingParameters.Add(this); + return context.CanBuildInnerChannelFactory(); + } + + public override StreamUpgradeProvider BuildClientStreamUpgradeProvider(BindingContext context) => new UnixPosixIdentitySecurityUpgradeProvider(this, context); + + public override T GetProperty(BindingContext context) + { + if (context == null) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(context)); + } + + if (typeof(T) == typeof(ISecurityCapabilities)) + { + return (T)(object)new SecurityCapabilities(true, true, true, Net.Security.ProtectionLevel.None, Net.Security.ProtectionLevel.None); + } + else if (typeof(T) == typeof(IdentityVerifier)) + { + return (T)(object)IdentityVerifier.CreateDefault(); + } + else + { + return context.GetInnerProperty(); + } + } + } +} + diff --git a/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/UnixPosixIdentitySecurityUpgradeProvider.cs b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/UnixPosixIdentitySecurityUpgradeProvider.cs new file mode 100644 index 00000000000..517b633a280 --- /dev/null +++ b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/UnixPosixIdentitySecurityUpgradeProvider.cs @@ -0,0 +1,112 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.IO; +using System.Net.Security; +using System.Runtime; +using System.ServiceModel.Security; +using System.Threading.Tasks; + +namespace System.ServiceModel.Channels +{ + internal class UnixPosixIdentitySecurityUpgradeProvider : StreamSecurityUpgradeProvider + { + internal const string UnixPosixUpgradeString = "application/unixposix"; + + public UnixPosixIdentitySecurityUpgradeProvider(UnixPosixIdentityBindingElement bindingElement, BindingContext context) + : base(context.Binding) + { + + } + + internal IdentityVerifier IdentityVerifier { get; private set; } + + public override StreamUpgradeInitiator CreateUpgradeInitiator(EndpointAddress remoteAddress, Uri via) + { + this.ThrowIfDisposedOrNotOpen(); + return new UnixPosixIdentitySecurityUpgradeInitiator(); + } + + protected override void OnAbort() + { + } + + protected override void OnClose(TimeSpan timeout) + { + } + + protected override IAsyncResult OnBeginClose(TimeSpan timeout, AsyncCallback callback, object state) + { + return Task.CompletedTask.ToApm(callback, state); + } + + protected override void OnEndClose(IAsyncResult result) + { + result.ToApmEnd(); + } + + protected internal override Task OnCloseAsync(TimeSpan timeout) + { + return Task.CompletedTask; + } + + protected override void OnOpen(TimeSpan timeout) + { + } + + protected override IAsyncResult OnBeginOpen(TimeSpan timeout, AsyncCallback callback, object state) + { + return Task.CompletedTask.ToApm(callback, state); + } + + protected override void OnEndOpen(IAsyncResult result) + { + result.ToApmEnd(); + } + + protected internal override Task OnOpenAsync(TimeSpan timeout) + { + return Task.CompletedTask; + } + + protected override void OnOpened() + { + base.OnOpened(); + + if (IdentityVerifier == null) + { + IdentityVerifier = IdentityVerifier.CreateDefault(); + } + } + + private class UnixPosixIdentitySecurityUpgradeInitiator : StreamSecurityUpgradeInitiator + { + private string _upgradeString = UnixPosixUpgradeString; + public UnixPosixIdentitySecurityUpgradeInitiator() + { + } + + public override SecurityMessageProperty GetRemoteSecurity() + { + return null;; + } + + public override string GetNextUpgrade() + { + string localUpgradeString = _upgradeString; + _upgradeString = null; + return localUpgradeString; + } + + public override Task InitiateUpgradeAsync(Stream stream) + { + if (stream == null) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(stream)); + } + + return Task.FromResult(stream); + } + } + } +} diff --git a/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/UnsafeNativeMethods.cs b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/UnsafeNativeMethods.cs new file mode 100644 index 00000000000..34ebf0e7951 --- /dev/null +++ b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/UnsafeNativeMethods.cs @@ -0,0 +1,24 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace System.ServiceModel.Channels +{ + internal static class UnsafeNativeMethods + { + public const int ERROR_INVALID_HANDLE = 6; + public const int ERROR_NOT_ENOUGH_MEMORY = 8; + public const int ERROR_OUTOFMEMORY = 14; + public const int ERROR_NO_SYSTEM_RESOURCES = 1450; + public const int WSAEADDRNOTAVAIL = 10049; + public const int WSAENETDOWN = 10050; + public const int WSAENETUNREACH = 10051; + public const int WSAENETRESET = 10052; + public const int WSAECONNABORTED = 10053; + public const int WSAECONNRESET = 10054; + public const int WSAENOBUFS = 10055; + public const int WSAETIMEDOUT = 10060; + public const int WSAECONNREFUSED = 10061; + public const int WSAEHOSTDOWN = 10064; + public const int WSAEHOSTUNREACH = 10065; + } +} diff --git a/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/TimeSpanHelper.cs b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/TimeSpanHelper.cs new file mode 100644 index 00000000000..f8ea1ef377e --- /dev/null +++ b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/TimeSpanHelper.cs @@ -0,0 +1,30 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics.Contracts; +using System.Globalization; + +namespace System.ServiceModel +{ + internal static class TimeSpanHelper + { + static public TimeSpan FromMinutes(int minutes, string text) + { + TimeSpan value = TimeSpan.FromTicks(TimeSpan.TicksPerMinute * minutes); + Contract.Assert(value == TimeSpan.Parse(text, CultureInfo.InvariantCulture), ""); + return value; + } + static public TimeSpan FromSeconds(int seconds, string text) + { + TimeSpan value = TimeSpan.FromTicks(TimeSpan.TicksPerSecond * seconds); + Contract.Assert(value == TimeSpan.Parse(text, CultureInfo.InvariantCulture), ""); + return value; + } + static public TimeSpan FromMilliseconds(int ms, string text) + { + TimeSpan value = TimeSpan.FromTicks(TimeSpan.TicksPerMillisecond * ms); + Contract.Assert(value == TimeSpan.Parse(text, CultureInfo.InvariantCulture), ""); + return value; + } + } +} diff --git a/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/UnixDomainSocketBinding.cs b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/UnixDomainSocketBinding.cs new file mode 100644 index 00000000000..ccacb1feb68 --- /dev/null +++ b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/UnixDomainSocketBinding.cs @@ -0,0 +1,118 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.ComponentModel; +using System.ServiceModel.Channels; +using System.Xml; + +namespace System.ServiceModel +{ + public class UnixDomainSocketBinding : Binding + { + private UnixDomainSocketTransportBindingElement _transport; + private BinaryMessageEncodingBindingElement _encoding; + private UnixDomainSocketSecurity _security = new UnixDomainSocketSecurity(); + + public UnixDomainSocketBinding() + { + Initialize(); + } + + public UnixDomainSocketBinding(UnixDomainSocketSecurityMode securityMode) + : this() + { + _security.Mode = securityMode; + } + + [DefaultValue(ConnectionOrientedTransportDefaults.TransferMode)] + public TransferMode TransferMode + { + get { return _transport.TransferMode; } + set { _transport.TransferMode = value; } + } + + [DefaultValue(UnixDomainSocketTransportDefaults.MaxBufferPoolSize)] + public long MaxBufferPoolSize + { + get { return _transport.MaxBufferPoolSize; } + set { _transport.MaxBufferPoolSize = value; } + } + + [DefaultValue(UnixDomainSocketTransportDefaults.MaxBufferSize)] + public int MaxBufferSize + { + get { return _transport.MaxBufferSize; } + set { _transport.MaxBufferSize = value; } + } + + public int MaxConnections + { + get { return _transport.ConnectionPoolSettings.MaxOutboundConnectionsPerEndpoint; } + set { _transport.ConnectionPoolSettings.MaxOutboundConnectionsPerEndpoint = value; } + } + + [DefaultValue(UnixDomainSocketTransportDefaults.MaxReceivedMessageSize)] + public long MaxReceivedMessageSize + { + get { return _transport.MaxReceivedMessageSize; } + set { _transport.MaxReceivedMessageSize = value; } + } + + public XmlDictionaryReaderQuotas ReaderQuotas + { + get { return _encoding.ReaderQuotas; } + set + { + if (value == null) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(value)); + } + + value.CopyTo(_encoding.ReaderQuotas); + } + } + + public override string Scheme { get { return _transport.Scheme; } } + + public EnvelopeVersion EnvelopeVersion + { + get { return EnvelopeVersion.Soap12; } + } + + public UnixDomainSocketSecurity Security + { + get { return _security; } + set + { + _security = value ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(value)); + } + } + + private void Initialize() + { + _transport = new UnixDomainSocketTransportBindingElement(); + _encoding = new BinaryMessageEncodingBindingElement(); + } + + public override BindingElementCollection CreateBindingElements() + { + // return collection of BindingElements + BindingElementCollection bindingElements = new BindingElementCollection(); + BindingElement transportSecurity = CreateTransportSecurity(); + if (transportSecurity != null) + { + bindingElements.Add(transportSecurity); + } + _transport.ExtendedProtectionPolicy = _security.Transport.ExtendedProtectionPolicy; + bindingElements.Add(_transport); + + return bindingElements.Clone(); + } + + private BindingElement CreateTransportSecurity() + { + return _security.CreateTransportSecurity(); + } + + } +} diff --git a/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/UnixDomainSocketClientCredentialType.cs b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/UnixDomainSocketClientCredentialType.cs new file mode 100644 index 00000000000..c9fec20c7dc --- /dev/null +++ b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/UnixDomainSocketClientCredentialType.cs @@ -0,0 +1,14 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace System.ServiceModel +{ + public enum UnixDomainSocketClientCredentialType + { + None, + Default, + Certificate, + Windows, + PosixIdentity, + } +} diff --git a/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/UnixDomainSocketClientCredentialTypeHelper.cs b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/UnixDomainSocketClientCredentialTypeHelper.cs new file mode 100644 index 00000000000..8f8f7a57a31 --- /dev/null +++ b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/UnixDomainSocketClientCredentialTypeHelper.cs @@ -0,0 +1,18 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace System.ServiceModel +{ + internal static class UnixDomainSocketClientCredentialTypeHelper + { + internal static bool IsDefined(UnixDomainSocketClientCredentialType value) + { + return (value == UnixDomainSocketClientCredentialType.None || + value == UnixDomainSocketClientCredentialType.Windows || + value == UnixDomainSocketClientCredentialType.Certificate || + value == UnixDomainSocketClientCredentialType.Default || + value == UnixDomainSocketClientCredentialType.PosixIdentity + ); + } + } +} diff --git a/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/UnixDomainSocketSecurity.cs b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/UnixDomainSocketSecurity.cs new file mode 100644 index 00000000000..5fada1c59eb --- /dev/null +++ b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/UnixDomainSocketSecurity.cs @@ -0,0 +1,67 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.ComponentModel; +using System.Diagnostics.Contracts; +using System.ServiceModel.Channels; + +namespace System.ServiceModel +{ + public sealed class UnixDomainSocketSecurity + { + internal const UnixDomainSocketSecurityMode DefaultMode = UnixDomainSocketSecurityMode.Transport; + + private UnixDomainSocketSecurityMode _mode; + + public UnixDomainSocketSecurity() : this(DefaultMode, new UnixDomainSocketTransportSecurity()) { } + + private UnixDomainSocketSecurity(UnixDomainSocketSecurityMode mode, UnixDomainSocketTransportSecurity transportSecurity) + { + Contract.Assert(UnixDomainSocketSecurityModeHelper.IsDefined(mode), + string.Format("Invalid SecurityMode value: {0} = {1} (default is {2} = {3}).", + (int)mode, + mode.ToString(), + (int)SecurityMode.Transport, + SecurityMode.Transport.ToString())); + + _mode = mode; + Transport = transportSecurity ?? new UnixDomainSocketTransportSecurity(); + } + + [DefaultValue(DefaultMode)] + public UnixDomainSocketSecurityMode Mode + { + get { return _mode; } + set + { + if (!UnixDomainSocketSecurityModeHelper.IsDefined(value)) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(value))); + } + _mode = value; + } + } + + public UnixDomainSocketTransportSecurity Transport { get; set; } + + internal BindingElement CreateTransportSecurity() + { + if (_mode == UnixDomainSocketSecurityMode.Transport || _mode == UnixDomainSocketSecurityMode.TransportCredentialOnly) + { + if(_mode == UnixDomainSocketSecurityMode.TransportCredentialOnly && Transport.ClientCredentialType != UnixDomainSocketClientCredentialType.PosixIdentity) + { + throw new NotSupportedException(); + } + return Transport.CreateTransportProtectionAndAuthentication(); + } + else if(_mode == UnixDomainSocketSecurityMode.None) + { + return null; + } + else + { + throw new NotSupportedException(); + } + } + } +} diff --git a/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/UnixDomainSocketSecurityMode.cs b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/UnixDomainSocketSecurityMode.cs new file mode 100644 index 00000000000..519f9da0756 --- /dev/null +++ b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/UnixDomainSocketSecurityMode.cs @@ -0,0 +1,23 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.ServiceModel +{ + public enum UnixDomainSocketSecurityMode + { + None, + Transport, + TransportCredentialOnly + } + + internal static class UnixDomainSocketSecurityModeHelper + { + public static bool IsDefined(UnixDomainSocketSecurityMode value) + { + return (value == UnixDomainSocketSecurityMode.None || + value == UnixDomainSocketSecurityMode.Transport || + value == UnixDomainSocketSecurityMode.TransportCredentialOnly); + } + } +} diff --git a/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/UnixDomainSocketTransportSecurity.cs b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/UnixDomainSocketTransportSecurity.cs new file mode 100644 index 00000000000..b264a588c98 --- /dev/null +++ b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/UnixDomainSocketTransportSecurity.cs @@ -0,0 +1,182 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.ComponentModel; +using System.Net.Security; +using System.Runtime.InteropServices; +using System.Security.Authentication; +using System.Security.Authentication.ExtendedProtection; +using System.ServiceModel.Channels; +using System.ServiceModel.Security; + +namespace System.ServiceModel +{ + public sealed class UnixDomainSocketTransportSecurity + { + internal const UnixDomainSocketClientCredentialType DefaultClientCredentialType = UnixDomainSocketClientCredentialType.Default; + internal const ProtectionLevel DefaultProtectionLevel = ProtectionLevel.EncryptAndSign; + + private UnixDomainSocketClientCredentialType _clientCredentialType; + private ProtectionLevel _protectionLevel; + private ExtendedProtectionPolicy _extendedProtectionPolicy; + private SslProtocols _sslProtocols; + + public UnixDomainSocketTransportSecurity() + { + _clientCredentialType = DefaultClientCredentialType; + _protectionLevel = DefaultProtectionLevel; + _extendedProtectionPolicy = Channels.ChannelBindingUtility.DefaultPolicy; + _sslProtocols = UnixDomainSocketTransportDefaults.SslProtocols; + } + + [DefaultValue(DefaultClientCredentialType)] + public UnixDomainSocketClientCredentialType ClientCredentialType + { + get { return _clientCredentialType; } + set + { + if (!UnixDomainSocketClientCredentialTypeHelper.IsDefined(value)) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(value))); + } + _clientCredentialType = value; + } + } + + [DefaultValue(DefaultProtectionLevel)] + public ProtectionLevel ProtectionLevel + { + get { return _protectionLevel; } + set + { + if (!Security.ProtectionLevelHelper.IsDefined(value)) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(value))); + } + + _protectionLevel = value; + } + } + + public ExtendedProtectionPolicy ExtendedProtectionPolicy + { + get + { + return _extendedProtectionPolicy; + } + set + { + if (value == null) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(value)); + } + + if (value.PolicyEnforcement == PolicyEnforcement.Always && + !ExtendedProtectionPolicy.OSSupportsExtendedProtection) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( + new PlatformNotSupportedException(SR.ExtendedProtectionNotSupported)); + } + _extendedProtectionPolicy = value; + } + } + + [DefaultValue(UnixDomainSocketTransportDefaults.SslProtocols)] + public SslProtocols SslProtocols + { + get { return _sslProtocols; } + set + { + SslProtocolsHelper.Validate(value); + _sslProtocols = value; + } + } + + private SslStreamSecurityBindingElement CreateSslBindingElement(bool requireClientCertificate) + { + if (_protectionLevel != ProtectionLevel.EncryptAndSign) + { + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format( + SR.UnsupportedSslProtectionLevel, _protectionLevel))); + } + + SslStreamSecurityBindingElement result = new SslStreamSecurityBindingElement(); + result.RequireClientCertificate = requireClientCertificate; + result.SslProtocols = _sslProtocols; + return result; + } + + internal BindingElement CreatePosixIdentityOnlyBinding() + { + return new UnixPosixIdentityBindingElement(); + } + + private static bool IsSslBindingElement(BindingElement element, UnixDomainSocketTransportSecurity transportSecurity) + { + SslStreamSecurityBindingElement ssl = element as SslStreamSecurityBindingElement; + if (ssl == null) + { + return false; + } + + transportSecurity.ProtectionLevel = ProtectionLevel.EncryptAndSign; + return true; + } + + internal BindingElement CreateTransportProtectionOnly() + { + return CreateSslBindingElement(false); + } + + internal static bool SetTransportProtectionOnly(BindingElement transport, UnixDomainSocketTransportSecurity transportSecurity) + { + return IsSslBindingElement(transport, transportSecurity); + } + + internal BindingElement CreateTransportProtectionAndAuthentication() + { + if (_clientCredentialType == UnixDomainSocketClientCredentialType.Default) + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + return new WindowsStreamSecurityBindingElement + { + ProtectionLevel = _protectionLevel + }; + } + else + { + return CreatePosixIdentityOnlyBinding(); + } + } + else if (_clientCredentialType == UnixDomainSocketClientCredentialType.Certificate) + { + return CreateSslBindingElement(true); + } + else if(_clientCredentialType == UnixDomainSocketClientCredentialType.Windows) + { + return new WindowsStreamSecurityBindingElement + { + ProtectionLevel = _protectionLevel + }; + } + else if (_clientCredentialType == UnixDomainSocketClientCredentialType.PosixIdentity) + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + throw new NotSupportedException(); + } + return CreatePosixIdentityOnlyBinding(); + } + else if(_clientCredentialType == UnixDomainSocketClientCredentialType.None) + { + return CreateTransportProtectionOnly(); + } + else + { + return null; + } + } + + } +} diff --git a/src/System.ServiceModel.UnixDomainSocket/tests/Channels/UnixDomainSocketTransportBindingElementTest.cs b/src/System.ServiceModel.UnixDomainSocket/tests/Channels/UnixDomainSocketTransportBindingElementTest.cs new file mode 100644 index 00000000000..0728695f2bb --- /dev/null +++ b/src/System.ServiceModel.UnixDomainSocket/tests/Channels/UnixDomainSocketTransportBindingElementTest.cs @@ -0,0 +1,25 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + + +using System; +using System.ServiceModel.Channels; +using Infrastructure.Common; +using Xunit; + +public static class UnixDomainSocketTransportBindingElementTest +{ + [WcfFact] + public static void Ctor_Default_Properties() + { + // Validates new UnixDomainSocketTransportBindingElement() initializes correct default property values + UnixDomainSocketTransportBindingElement element = new UnixDomainSocketTransportBindingElement(); + + Assert.True(String.Equals(element.Scheme, "net.uds"), String.Format("Scheme property expected '{0}' but actual was '{1}'", "net.uds", element.Scheme)); + + // Validate only a non-null ConnectionPoolSetting. + // Its own default values are validated in that type's test methods + Assert.True(element.ConnectionPoolSettings != null, "ConnectionPoolSettings should not be null."); + } +} diff --git a/src/System.ServiceModel.UnixDomainSocket/tests/ServiceModel/UnixDomainSocketBindingTest.cs b/src/System.ServiceModel.UnixDomainSocket/tests/ServiceModel/UnixDomainSocketBindingTest.cs new file mode 100644 index 00000000000..851af53c8be --- /dev/null +++ b/src/System.ServiceModel.UnixDomainSocket/tests/ServiceModel/UnixDomainSocketBindingTest.cs @@ -0,0 +1,106 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + + +using System; +using System.ServiceModel; +using System.Xml; +using Infrastructure.Common; +using Xunit; + +public static class UnixDomainSocketBindingTest +{ + [WcfTheory] + [InlineData(UnixDomainSocketSecurityMode.None)] + [InlineData(UnixDomainSocketSecurityMode.Transport)] + [InlineData(UnixDomainSocketSecurityMode.TransportCredentialOnly)] + public static void Ctor_Default_Initializes_Properties(UnixDomainSocketSecurityMode securityMode) + { + var binding = new UnixDomainSocketBinding(securityMode); + + Assert.Equal(EnvelopeVersion.Soap12, binding.EnvelopeVersion); + Assert.Equal(512 * 1024, binding.MaxBufferPoolSize); + Assert.Equal(65536, binding.MaxBufferSize); + Assert.True(TestHelpers.XmlDictionaryReaderQuotasAreEqual(binding.ReaderQuotas, new XmlDictionaryReaderQuotas()), "XmlDictionaryReaderQuotas"); + Assert.Equal("net.uds", binding.Scheme); + Assert.Equal(TransferMode.Buffered, binding.TransferMode); + Assert.Equal(securityMode, binding.Security.Mode); + } + + [WcfTheory] + [InlineData(TransferMode.Buffered)] + [InlineData(TransferMode.Streamed)] + [InlineData(TransferMode.StreamedRequest)] + [InlineData(TransferMode.StreamedResponse)] + public static void TransferMode_Property_Sets(TransferMode mode) + { + UnixDomainSocketBinding binding = new UnixDomainSocketBinding(); + binding.TransferMode = mode; + Assert.Equal(mode, binding.TransferMode); + } + + [WcfTheory] + [InlineData(0)] + [InlineData(Int64.MaxValue)] + public static void MaxBufferPoolSize_Property_Sets(long value) + { + UnixDomainSocketBinding binding = new UnixDomainSocketBinding(); + binding.MaxBufferPoolSize = value; + Assert.Equal(value, binding.MaxBufferPoolSize); + } + + [WcfTheory] + [InlineData(1)] + [InlineData(int.MaxValue)] + public static void MaxBufferSize_Property_Sets(int value) + { + UnixDomainSocketBinding binding = new UnixDomainSocketBinding(); + binding.MaxBufferSize = value; + Assert.Equal(value, binding.MaxBufferSize); + } + + [WcfTheory] + [InlineData(0)] + [InlineData(-1)] + public static void MaxBufferSize_Property_Set_With_Invalid_Value_Throws(int value) + { + UnixDomainSocketBinding binding = new UnixDomainSocketBinding(); + Assert.Throws(() => binding.MaxBufferSize = value); + } + + [WcfTheory] + [InlineData(1)] + [InlineData(Int64.MaxValue)] + public static void MaxReceivedMessageSize_Property_Sets(long value) + { + UnixDomainSocketBinding binding = new UnixDomainSocketBinding(); + binding.MaxReceivedMessageSize = value; + Assert.Equal(value, binding.MaxReceivedMessageSize); + } + + [WcfTheory] + [InlineData(0)] + [InlineData(-1)] + public static void MaxReceivedMessageSize_Property_Set_Invalid_Value_Throws(long value) + { + UnixDomainSocketBinding binding = new UnixDomainSocketBinding(); + Assert.Throws(() => binding.MaxReceivedMessageSize = value); + } + + [WcfFact] + public static void Security_Property_Sets() + { + UnixDomainSocketBinding binding = new UnixDomainSocketBinding(); + UnixDomainSocketSecurity security = new UnixDomainSocketSecurity(); + binding.Security = security; + Assert.Equal(security, binding.Security); + } + + [WcfFact] + public static void Security_Property_Set_Null_Throws() + { + UnixDomainSocketBinding binding = new UnixDomainSocketBinding(); + Assert.Throws(() => binding.Security = null); + } +} diff --git a/src/System.ServiceModel.UnixDomainSocket/tests/ServiceModel/UnixDomainSocketSecurityTest.cs b/src/System.ServiceModel.UnixDomainSocket/tests/ServiceModel/UnixDomainSocketSecurityTest.cs new file mode 100644 index 00000000000..612c8bd0e18 --- /dev/null +++ b/src/System.ServiceModel.UnixDomainSocket/tests/ServiceModel/UnixDomainSocketSecurityTest.cs @@ -0,0 +1,46 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + + +using System; +using System.ServiceModel; +using Infrastructure.Common; +using Xunit; + +public static class UnixDomainSocketSecurityTest +{ + [WcfFact] + public static void Ctor_Default_Initializes_Properties() + { + UnixDomainSocketSecurity security = new UnixDomainSocketSecurity(); + Assert.Equal(UnixDomainSocketSecurityMode.Transport, security.Mode); + } + + [WcfTheory] + [InlineData(UnixDomainSocketSecurityMode.None)] + [InlineData(UnixDomainSocketSecurityMode.Transport)] + public static void Mode_Property_Sets(UnixDomainSocketSecurityMode mode) + { + UnixDomainSocketSecurity security = new UnixDomainSocketSecurity(); + security.Mode = mode; + Assert.Equal(mode, security.Mode); + } + + [WcfFact] + public static void Mode_Property_Set_Invalid_Value_Throws() + { + UnixDomainSocketSecurity security = new UnixDomainSocketSecurity(); + Assert.Throws(() => security.Mode = (UnixDomainSocketSecurityMode)999); + } + + [WcfFact] + public static void Transport_Property_Sets() + { + UnixDomainSocketSecurity security = new UnixDomainSocketSecurity(); + + UnixDomainSocketTransportSecurity newSecurity = new UnixDomainSocketTransportSecurity(); + security.Transport = newSecurity; + Assert.Equal(newSecurity, security.Transport); + } +} diff --git a/src/System.ServiceModel.UnixDomainSocket/tests/ServiceModel/UnixDomainSocketTransportSecurityTest.cs b/src/System.ServiceModel.UnixDomainSocket/tests/ServiceModel/UnixDomainSocketTransportSecurityTest.cs new file mode 100644 index 00000000000..4015a19cc12 --- /dev/null +++ b/src/System.ServiceModel.UnixDomainSocket/tests/ServiceModel/UnixDomainSocketTransportSecurityTest.cs @@ -0,0 +1,42 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + + +using System; +using System.ServiceModel; +using Infrastructure.Common; +using Xunit; + +public static class UnixDomainSocketTransportSecurityTest +{ + [WcfFact] + public static void Ctor_Default_Properties() + { + // new UnixDomainSocketTransportSecurity() initializes correct defaults + UnixDomainSocketTransportSecurity transport = new UnixDomainSocketTransportSecurity(); + + Assert.True(transport.ClientCredentialType == UnixDomainSocketClientCredentialType.Default, + String.Format("ClientCredentialType should have been '{0}' but was '{1}'", UnixDomainSocketClientCredentialType.Default, transport.ClientCredentialType)); + } + + [WcfTheory] + [InlineData(UnixDomainSocketClientCredentialType.None)] + [InlineData(UnixDomainSocketClientCredentialType.Windows)] + [InlineData(UnixDomainSocketClientCredentialType.Certificate)] + [InlineData(UnixDomainSocketClientCredentialType.Default)] + [InlineData(UnixDomainSocketClientCredentialType.PosixIdentity)] + public static void ClientCredentialType_Property_Sets(UnixDomainSocketClientCredentialType credentialType) + { + UnixDomainSocketTransportSecurity transport = new UnixDomainSocketTransportSecurity(); + transport.ClientCredentialType = credentialType; + Assert.Equal(credentialType, transport.ClientCredentialType); + } + + [WcfFact] + public static void ClientCredentialType_Property_Set_Invalid_Value_Throws() + { + UnixDomainSocketTransportSecurity transport = new UnixDomainSocketTransportSecurity(); + Assert.Throws(() => transport.ClientCredentialType = (UnixDomainSocketClientCredentialType)999); + } +} diff --git a/src/System.ServiceModel.UnixDomainSocket/tests/System.ServiceModel.UnixDomainSocket.Tests.csproj b/src/System.ServiceModel.UnixDomainSocket/tests/System.ServiceModel.UnixDomainSocket.Tests.csproj new file mode 100644 index 00000000000..4ac0ca54ef2 --- /dev/null +++ b/src/System.ServiceModel.UnixDomainSocket/tests/System.ServiceModel.UnixDomainSocket.Tests.csproj @@ -0,0 +1,15 @@ + + + $(UnitTestTargetFrameworks) + false + true + false + + + + + + + + + From a21cad90940a8761718ffaa4dc0a7fd653868726 Mon Sep 17 00:00:00 2001 From: Biroj Nayak Date: Sat, 14 Oct 2023 01:03:06 +0000 Subject: [PATCH 2/4] review comments --- .../tests/Scenarios/Binding/UDS/UDSBindingTests.cs | 1 + .../src/Resources/strings.resx | 3 +++ .../src/Resources/xlf/strings.cs.xlf | 5 +++++ .../src/Resources/xlf/strings.de.xlf | 5 +++++ .../src/Resources/xlf/strings.es.xlf | 5 +++++ .../src/Resources/xlf/strings.fr.xlf | 5 +++++ .../src/Resources/xlf/strings.it.xlf | 5 +++++ .../src/Resources/xlf/strings.ja.xlf | 5 +++++ .../src/Resources/xlf/strings.ko.xlf | 5 +++++ .../src/Resources/xlf/strings.pl.xlf | 5 +++++ .../src/Resources/xlf/strings.pt-BR.xlf | 5 +++++ .../src/Resources/xlf/strings.ru.xlf | 5 +++++ .../src/Resources/xlf/strings.tr.xlf | 5 +++++ .../src/Resources/xlf/strings.zh-Hans.xlf | 5 +++++ .../src/Resources/xlf/strings.zh-Hant.xlf | 5 +++++ .../System/ServiceModel/UnixDomainSocketSecurity.cs | 10 ++++++++-- .../tests/ServiceModel/UnixDomainSocketSecurityTest.cs | 5 ++++- 17 files changed, 81 insertions(+), 3 deletions(-) diff --git a/src/System.Private.ServiceModel/tests/Scenarios/Binding/UDS/UDSBindingTests.cs b/src/System.Private.ServiceModel/tests/Scenarios/Binding/UDS/UDSBindingTests.cs index 21837176b7f..c8e4965c565 100644 --- a/src/System.Private.ServiceModel/tests/Scenarios/Binding/UDS/UDSBindingTests.cs +++ b/src/System.Private.ServiceModel/tests/Scenarios/Binding/UDS/UDSBindingTests.cs @@ -97,6 +97,7 @@ public void WindowsAuth() } [WcfFact] + [Issue(2870, OS = OSID.OSX)] [Condition(nameof(SSL_Available))] [OuterLoop] private void BasicCertAsTransport() diff --git a/src/System.ServiceModel.UnixDomainSocket/src/Resources/strings.resx b/src/System.ServiceModel.UnixDomainSocket/src/Resources/strings.resx index 99f43d70532..26253d13cdd 100644 --- a/src/System.ServiceModel.UnixDomainSocket/src/Resources/strings.resx +++ b/src/System.ServiceModel.UnixDomainSocket/src/Resources/strings.resx @@ -204,4 +204,7 @@ Transfer mode {0} is not supported by {1}. + +The value '{1}' is not supported in this context for the binding security property '{0}'. + diff --git a/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.cs.xlf b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.cs.xlf index 7676d7c7d28..ce44e3912c9 100644 --- a/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.cs.xlf +++ b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.cs.xlf @@ -132,6 +132,11 @@ Nelze vyřešit název hostitele identifikátoru URI {0} pomocí služby DNS. + + The value '{1}' is not supported in this context for the binding security property '{0}'. + The value '{1}' is not supported in this context for the binding security property '{0}'. + + The protection level '{0}' was specified, yet SSL transport security only supports EncryptAndSign. Byla zadána úroveň zabezpečení {0}, ale zabezpečení přenosu SSL podporuje pouze EncryptAndSign. diff --git a/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.de.xlf b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.de.xlf index 0fb81e561ef..062f66de53d 100644 --- a/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.de.xlf +++ b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.de.xlf @@ -132,6 +132,11 @@ Der Hostname von URI "{0}" kann nicht mithilfe von DNS aufgelöst werden. + + The value '{1}' is not supported in this context for the binding security property '{0}'. + The value '{1}' is not supported in this context for the binding security property '{0}'. + + The protection level '{0}' was specified, yet SSL transport security only supports EncryptAndSign. Die Schutzebene "{0}" war angegeben, die SSL-Transportsicherheit unterstützt jedoch nur EncryptAndSign. diff --git a/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.es.xlf b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.es.xlf index d82f259155b..b5a313140a6 100644 --- a/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.es.xlf +++ b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.es.xlf @@ -132,6 +132,11 @@ No se puede resolver el nombre de host del URI "{0}" con DNS. + + The value '{1}' is not supported in this context for the binding security property '{0}'. + The value '{1}' is not supported in this context for the binding security property '{0}'. + + The protection level '{0}' was specified, yet SSL transport security only supports EncryptAndSign. Se especificó el nivel de protección "{0}", pero la seguridad de transporte SSL solo admite EncryptAndSign. diff --git a/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.fr.xlf b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.fr.xlf index 779a2b59b9c..bae74f85e5a 100644 --- a/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.fr.xlf +++ b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.fr.xlf @@ -132,6 +132,11 @@ Impossible de résoudre le nom d'hôte de l'URI '{0}' à l'aide de DNS. + + The value '{1}' is not supported in this context for the binding security property '{0}'. + The value '{1}' is not supported in this context for the binding security property '{0}'. + + The protection level '{0}' was specified, yet SSL transport security only supports EncryptAndSign. Le niveau de protection '{0}' a été spécifié, mais la sécurité du transport SSL prend uniquement en charge EncryptAndSign. diff --git a/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.it.xlf b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.it.xlf index 6e688a89fe6..5b57ae92926 100644 --- a/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.it.xlf +++ b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.it.xlf @@ -132,6 +132,11 @@ Impossibile risolvere il nome host dell'URI "{0}" tramite DNS. + + The value '{1}' is not supported in this context for the binding security property '{0}'. + The value '{1}' is not supported in this context for the binding security property '{0}'. + + The protection level '{0}' was specified, yet SSL transport security only supports EncryptAndSign. È stato specificato il livello di protezione '{0}', ma la sicurezza del trasporto SSL supporta solo EncryptAndSign. diff --git a/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.ja.xlf b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.ja.xlf index f8b912a2909..a41a9c64eb0 100644 --- a/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.ja.xlf +++ b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.ja.xlf @@ -132,6 +132,11 @@ DNS を使用して URI "{0}" のホスト名を解決できません。 + + The value '{1}' is not supported in this context for the binding security property '{0}'. + The value '{1}' is not supported in this context for the binding security property '{0}'. + + The protection level '{0}' was specified, yet SSL transport security only supports EncryptAndSign. 保護レベル '{0}' が指定されましたが、SSL トランスポート セキュリティでサポートされるのは EncryptAndSign のみです。 diff --git a/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.ko.xlf b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.ko.xlf index d70a7b9ac03..511ab2593c2 100644 --- a/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.ko.xlf +++ b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.ko.xlf @@ -132,6 +132,11 @@ DNS를 사용하여 URI "{0}"의 호스트 이름을 확인할 수 없습니다. + + The value '{1}' is not supported in this context for the binding security property '{0}'. + The value '{1}' is not supported in this context for the binding security property '{0}'. + + The protection level '{0}' was specified, yet SSL transport security only supports EncryptAndSign. 보호 수준 '{0}'이(가) 지정되었지만, SSL 전송 보안은 EncryptAndSign만 지원합니다. diff --git a/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.pl.xlf b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.pl.xlf index 858512bc044..5a911c97b2a 100644 --- a/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.pl.xlf +++ b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.pl.xlf @@ -132,6 +132,11 @@ Nie można rozpoznać nazwy hosta o identyfikatorze URI „{0}” za pomocą usługi DNS. + + The value '{1}' is not supported in this context for the binding security property '{0}'. + The value '{1}' is not supported in this context for the binding security property '{0}'. + + The protection level '{0}' was specified, yet SSL transport security only supports EncryptAndSign. Określono poziom zabezpieczeń „{0}”, jednak zabezpieczenia transportowe protokołu SSL obsługują tylko metodę EncryptAndSign. diff --git a/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.pt-BR.xlf b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.pt-BR.xlf index 165daebcaf3..d163941ec4e 100644 --- a/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.pt-BR.xlf +++ b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.pt-BR.xlf @@ -132,6 +132,11 @@ Não é possível resolver nome de host de URI "{0}" usando DNS. + + The value '{1}' is not supported in this context for the binding security property '{0}'. + The value '{1}' is not supported in this context for the binding security property '{0}'. + + The protection level '{0}' was specified, yet SSL transport security only supports EncryptAndSign. O nível de proteção '{0}' foi especificado, ainda assim a segurança do transporte SSL apenas dá suporte a EncryptAndSign. diff --git a/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.ru.xlf b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.ru.xlf index 7ec68b6e857..35ea2f2071c 100644 --- a/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.ru.xlf +++ b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.ru.xlf @@ -132,6 +132,11 @@ Не удается разрешить имя узла URI "{0}" с помощью DNS. + + The value '{1}' is not supported in this context for the binding security property '{0}'. + The value '{1}' is not supported in this context for the binding security property '{0}'. + + The protection level '{0}' was specified, yet SSL transport security only supports EncryptAndSign. Указан уровень защиты "{0}", однако защита транспорта SSL поддерживает только EncryptAndSign. diff --git a/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.tr.xlf b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.tr.xlf index 78dd48c3ef1..c7c820846eb 100644 --- a/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.tr.xlf +++ b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.tr.xlf @@ -132,6 +132,11 @@ DNS kullanılarak URI "{0}" ana bilgisayar adı çözümlenemiyor. + + The value '{1}' is not supported in this context for the binding security property '{0}'. + The value '{1}' is not supported in this context for the binding security property '{0}'. + + The protection level '{0}' was specified, yet SSL transport security only supports EncryptAndSign. SSL aktarım güvenliği yalnızca EncryptAndSign özelliğini desteklese de, '{0}' koruma düzeyi belirtildi. diff --git a/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.zh-Hans.xlf b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.zh-Hans.xlf index 54def095f6c..847df5c3f50 100644 --- a/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.zh-Hans.xlf +++ b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.zh-Hans.xlf @@ -132,6 +132,11 @@ 无法使用 DNS 解析 URI“{0}”的主机名。 + + The value '{1}' is not supported in this context for the binding security property '{0}'. + The value '{1}' is not supported in this context for the binding security property '{0}'. + + The protection level '{0}' was specified, yet SSL transport security only supports EncryptAndSign. 指定了保护级别“{0}”,但 SSL 传输安全性仅支持 EncryptAndSign。 diff --git a/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.zh-Hant.xlf b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.zh-Hant.xlf index d0eb2f2b4be..164915b1310 100644 --- a/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.zh-Hant.xlf +++ b/src/System.ServiceModel.UnixDomainSocket/src/Resources/xlf/strings.zh-Hant.xlf @@ -132,6 +132,11 @@ 無法使用 DNS 解析 URI "{0}" 的主機名稱。 + + The value '{1}' is not supported in this context for the binding security property '{0}'. + The value '{1}' is not supported in this context for the binding security property '{0}'. + + The protection level '{0}' was specified, yet SSL transport security only supports EncryptAndSign. 已指定保護層級 '{0}',但是 SSL 傳輸安全性只支援 EncryptAndSign。 diff --git a/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/UnixDomainSocketSecurity.cs b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/UnixDomainSocketSecurity.cs index 5fada1c59eb..83c883c122d 100644 --- a/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/UnixDomainSocketSecurity.cs +++ b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/UnixDomainSocketSecurity.cs @@ -3,6 +3,7 @@ using System.ComponentModel; using System.Diagnostics.Contracts; +using System.Runtime.InteropServices; using System.ServiceModel.Channels; namespace System.ServiceModel @@ -13,7 +14,12 @@ public sealed class UnixDomainSocketSecurity private UnixDomainSocketSecurityMode _mode; - public UnixDomainSocketSecurity() : this(DefaultMode, new UnixDomainSocketTransportSecurity()) { } + public UnixDomainSocketSecurity() + { + _mode = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? + UnixDomainSocketSecurityMode.Transport : UnixDomainSocketSecurityMode.TransportCredentialOnly; + Transport = new UnixDomainSocketTransportSecurity(); + } private UnixDomainSocketSecurity(UnixDomainSocketSecurityMode mode, UnixDomainSocketTransportSecurity transportSecurity) { @@ -50,7 +56,7 @@ internal BindingElement CreateTransportSecurity() { if(_mode == UnixDomainSocketSecurityMode.TransportCredentialOnly && Transport.ClientCredentialType != UnixDomainSocketClientCredentialType.PosixIdentity) { - throw new NotSupportedException(); + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.Format(SR.UnsupportedSecuritySetting, "Mode", _mode))); } return Transport.CreateTransportProtectionAndAuthentication(); } diff --git a/src/System.ServiceModel.UnixDomainSocket/tests/ServiceModel/UnixDomainSocketSecurityTest.cs b/src/System.ServiceModel.UnixDomainSocket/tests/ServiceModel/UnixDomainSocketSecurityTest.cs index 612c8bd0e18..284d3d7b35e 100644 --- a/src/System.ServiceModel.UnixDomainSocket/tests/ServiceModel/UnixDomainSocketSecurityTest.cs +++ b/src/System.ServiceModel.UnixDomainSocket/tests/ServiceModel/UnixDomainSocketSecurityTest.cs @@ -4,6 +4,7 @@ using System; +using System.Runtime.InteropServices; using System.ServiceModel; using Infrastructure.Common; using Xunit; @@ -14,7 +15,9 @@ public static class UnixDomainSocketSecurityTest public static void Ctor_Default_Initializes_Properties() { UnixDomainSocketSecurity security = new UnixDomainSocketSecurity(); - Assert.Equal(UnixDomainSocketSecurityMode.Transport, security.Mode); + UnixDomainSocketSecurityMode mode = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? + UnixDomainSocketSecurityMode.Transport : UnixDomainSocketSecurityMode.TransportCredentialOnly; + Assert.Equal(mode, security.Mode); } [WcfTheory] From b660de38d56c99cc6bb46d4f4e76cf022d202bfe Mon Sep 17 00:00:00 2001 From: Biroj Nayak Date: Fri, 20 Oct 2023 00:21:39 +0000 Subject: [PATCH 3/4] incorporated review comments --- .../ServiceModel/UnixDomainSocketSecurity.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/UnixDomainSocketSecurity.cs b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/UnixDomainSocketSecurity.cs index 83c883c122d..39bb102cc05 100644 --- a/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/UnixDomainSocketSecurity.cs +++ b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/UnixDomainSocketSecurity.cs @@ -10,14 +10,16 @@ namespace System.ServiceModel { public sealed class UnixDomainSocketSecurity { - internal const UnixDomainSocketSecurityMode DefaultMode = UnixDomainSocketSecurityMode.Transport; + private static UnixDomainSocketSecurityMode s_defaultMode = + RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? + UnixDomainSocketSecurityMode.Transport : UnixDomainSocketSecurityMode.TransportCredentialOnly; + private UnixDomainSocketSecurityMode _mode; public UnixDomainSocketSecurity() { - _mode = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? - UnixDomainSocketSecurityMode.Transport : UnixDomainSocketSecurityMode.TransportCredentialOnly; + _mode = s_defaultMode; Transport = new UnixDomainSocketTransportSecurity(); } @@ -27,14 +29,14 @@ private UnixDomainSocketSecurity(UnixDomainSocketSecurityMode mode, UnixDomainSo string.Format("Invalid SecurityMode value: {0} = {1} (default is {2} = {3}).", (int)mode, mode.ToString(), - (int)SecurityMode.Transport, - SecurityMode.Transport.ToString())); + (int)s_defaultMode, + s_defaultMode.ToString())); _mode = mode; Transport = transportSecurity ?? new UnixDomainSocketTransportSecurity(); } - [DefaultValue(DefaultMode)] + public UnixDomainSocketSecurityMode Mode { get { return _mode; } @@ -54,7 +56,9 @@ internal BindingElement CreateTransportSecurity() { if (_mode == UnixDomainSocketSecurityMode.Transport || _mode == UnixDomainSocketSecurityMode.TransportCredentialOnly) { - if(_mode == UnixDomainSocketSecurityMode.TransportCredentialOnly && Transport.ClientCredentialType != UnixDomainSocketClientCredentialType.PosixIdentity) + if((_mode == UnixDomainSocketSecurityMode.TransportCredentialOnly && Transport.ClientCredentialType != UnixDomainSocketClientCredentialType.PosixIdentity) + || + (_mode == UnixDomainSocketSecurityMode.Transport && Transport.ClientCredentialType == UnixDomainSocketClientCredentialType.PosixIdentity)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.Format(SR.UnsupportedSecuritySetting, "Mode", _mode))); } From 95ef200cbe2eb7c638d2c75d2faceaa8be4a56f4 Mon Sep 17 00:00:00 2001 From: Biroj Nayak Date: Fri, 20 Oct 2023 19:10:49 +0000 Subject: [PATCH 4/4] Incorporated the feedback for socket connection --- .../src/System/ServiceModel/Channels/SocketConnection.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/SocketConnection.cs b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/SocketConnection.cs index 7f4097c7a3a..316ecfe0c9d 100644 --- a/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/SocketConnection.cs +++ b/src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/SocketConnection.cs @@ -155,9 +155,9 @@ private void AbortWrite() public ValueTask ReadAsync(Memory buffer, TimeSpan timeout) { - if (buffer.Length <= 0) + if (buffer.Length < 0) { - throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(buffer.Length), buffer.Length, SR.ValueMustBePositive)); + throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(buffer.Length), buffer.Length, SR.ValueMustBeNonNegative)); } ThrowIfNotOpen();