Skip to content

Commit

Permalink
Fix UnixDomainSocketBinding default security issue on Windows. (#5627)
Browse files Browse the repository at this point in the history
  • Loading branch information
imcarolwang authored Aug 21, 2024
1 parent b5bbbf9 commit 5c73c1a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,9 @@ public void WindowsAuth()
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()
};
var uri = new Uri("net.uds://" + UDS.GetUDSFilePath());
factory = new System.ServiceModel.ChannelFactory<IEchoService>(binding,
new System.ServiceModel.EndpointAddress(uriBuilder.ToString()));
new System.ServiceModel.EndpointAddress(uri));
channel = factory.CreateChannel();
((IChannel)channel).Open();
string result = channel.Echo(testString);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected override TChannel OnCreateChannel(EndpointAddress address, Uri via)
{
if(address.Identity == null)
{
var hostIdentity = new DnsEndpointIdentity(address.Uri.Host ?? "localhost");
var hostIdentity = new DnsEndpointIdentity(string.IsNullOrEmpty(address.Uri.Host) ? "localhost" : address.Uri.Host);
var uriBuilder = new UriBuilder(address.Uri);
uriBuilder.Host = null;
address = new EndpointAddress(uriBuilder.Uri, hostIdentity,address.Headers.ToArray());
Expand Down

0 comments on commit 5c73c1a

Please sign in to comment.