Reputation: 901
We add as a Service Reference a WCF project. When we configure the communication client without security just all works fine.
<security mode="None" />
And now the .cs file on a UWP app without the security configuration.
var binding = new NetTcpBinding(SecurityMode.None);
binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.None;
client = new ServiceReference1Client(binding, new EndpointAddress(new Uri("net.tcp://localhost:1234/ServiceReference1")));
This sentences with no security in .exe.config just works as in Windows 8.1
<security mode="Transport">
<transport clientCredentialType="Windows"/>
</security>
And now the .cs file on a UWP app with the same security configuration.
var binding = new NetTcpBinding(SecurityMode.Transport);
binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows;
client = new ServiceReference1Client(binding, new EndpointAddress(new Uri("net.tcp://localhost:1234/ServiceReference1")));
Running the application with security configuration thows this exception:
System.PlatformNotSupportedException
"SecureConnectionDuplexSession is not supported."
And here is the StrackTrace:
System.ServiceModel.Channels.FramingDuplexSessionChannel.FramingConnectionDuplexSession.CreateSession(FramingDuplexSessionChannel channel, StreamUpgradeProvider upgrade)
System.ServiceModel.Channels.FramingDuplexSessionChannel..ctor(ChannelManagerBase factory, IConnectionOrientedTransportFactorySettings settings, EndpointAddress remoteAddresss, Uri via, Boolean exposeConnectionProperty)
System.ServiceModel.Channels.ClientFramingDuplexSessionChannel..ctor(ChannelManagerBase factory, IConnectionOrientedTransportChannelFactorySettings settings, EndpointAddress remoteAddresss, Uri via, IConnectionInitiator connectionInitiator, ConnectionPool connectionPool, Boolean exposeConnectionProperty, Boolean flowIdentity)
System.ServiceModel.Channels.ConnectionOrientedTransportChannelFactory`1.OnCreateChannel(EndpointAddress address, Uri via)
System.ServiceModel.Channels.ChannelFactoryBase`1.InternalCreateChannel(EndpointAddress address, Uri via)
System.ServiceModel.Channels.ChannelFactoryBase`1.CreateChannel(EndpointAddress address, Uri via)
System.ServiceModel.Channels.ServiceChannelFactory.ServiceChannelFactoryOverDuplexSession.CreateInnerChannelBinder(EndpointAddress to, Uri via)
System.ServiceModel.Channels.ServiceChannelFactory.CreateServiceChannel(EndpointAddress address, Uri via)
System.ServiceModel.Channels.ServiceChannelFactory.CreateChannel[TChannel](EndpointAddress address, Uri via)
System.ServiceModel.ChannelFactory`1.CreateChannel(EndpointAddress address, Uri via)
System.ServiceModel.ChannelFactory`1.CreateChannel()
System.ServiceModel.ClientBase`1.CreateChannel()
System.ServiceModel.ClientBase`1.CreateChannelInternal()
System.ServiceModel.ClientBase`1.get_Channel()
Fooooooo(String jsonRequest)
Fooooooo.<Boooooo>d__0`1.MoveNext()
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
Fooooo.<Booooo>d__5.MoveNext()
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
Foooo.<Boooooo>d__12.MoveNext()
I see that with the security on .exe.config
<security mode="Transport">
<transport clientCredentialType="Windows"/>
</security>
The client state is in Opened, but the client.InnerChannel threw an exception of type System.PlatformNotSupportedException
As @glen-thomas said, I try this configuration:
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
But in this case the client state is in Faultet and threw this exception
System.ServiceModel.CommunicationObjectFaultedException
"The communication object, System.ServiceModel.ChannelFactory1[Fooo], cannot be used for communication because it is in the Faulted state."
On the dotnet\wcf
page of github, we can see that this is currently not suported.
https://github.com/dotnet/wcf/blob/master/release-notes/SupportedFeatures-v1.0.0-rc1.md
Upvotes: 1
Views: 1677
Reputation: 10627
Transport security mode of NetTcpBinding is currently not supported by uwp.You can use the basicHttpBinding instead of the NetTcpBinding. The WCF which uses the basicHttpBinding with the Windows Authentication can be consumed by the UWP.
Upvotes: 1
Reputation: 10744
If the security of the connection is important but not who is connecting, try enabling transport security, but set the credential type to None. This will secure the connection but allow anonymous clients to connect.
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
Alternatively, you might be able to solve your problem by adding the Enterprise Authentication and Private Networks(Client & Server) capabilities to your UWP application.
Upvotes: 1