Skip to content

Commit 5c73c1a

Browse files
authored
Fix UnixDomainSocketBinding default security issue on Windows. (#5627)
1 parent b5bbbf9 commit 5c73c1a

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

src/System.Private.ServiceModel/tests/Scenarios/Binding/UDS/UDSBindingTests.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,9 @@ public void WindowsAuth()
7575
System.ServiceModel.UnixDomainSocketBinding binding = new UnixDomainSocketBinding(System.ServiceModel.UnixDomainSocketSecurityMode.Transport);
7676
binding.Security.Transport.ClientCredentialType = System.ServiceModel.UnixDomainSocketClientCredentialType.Windows;
7777

78-
var uriBuilder = new UriBuilder()
79-
{
80-
Scheme = "net.uds",
81-
Path = UDS.GetUDSFilePath()
82-
};
78+
var uri = new Uri("net.uds://" + UDS.GetUDSFilePath());
8379
factory = new System.ServiceModel.ChannelFactory<IEchoService>(binding,
84-
new System.ServiceModel.EndpointAddress(uriBuilder.ToString()));
80+
new System.ServiceModel.EndpointAddress(uri));
8581
channel = factory.CreateChannel();
8682
((IChannel)channel).Open();
8783
string result = channel.Echo(testString);

src/System.ServiceModel.UnixDomainSocket/src/System/ServiceModel/Channels/UnixDomainSocketChannelFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ protected override TChannel OnCreateChannel(EndpointAddress address, Uri via)
4040
{
4141
if(address.Identity == null)
4242
{
43-
var hostIdentity = new DnsEndpointIdentity(address.Uri.Host ?? "localhost");
43+
var hostIdentity = new DnsEndpointIdentity(string.IsNullOrEmpty(address.Uri.Host) ? "localhost" : address.Uri.Host);
4444
var uriBuilder = new UriBuilder(address.Uri);
4545
uriBuilder.Host = null;
4646
address = new EndpointAddress(uriBuilder.Uri, hostIdentity,address.Headers.ToArray());

0 commit comments

Comments
 (0)