Intranet Silverlight 5应用程序中的传输级别安全性

时间:2017-08-09 04:17:34

标签: wcf silverlight wcf-security nettcpbinding custom-binding

我正在Intranet Silverlight 5应用程序中实现传输级别安全性。

使用的绑定是自定义netTcpBinding,在服务器端,我使用以下设置和PrincipalPermission启用了安全性。

<customBinding>
    <binding closeTimeout="00:05:00" openTimeout="00:05:00" receiveTimeout="02:00:00" sendTimeout="00:05:00">
      <binaryMessageEncoding maxSessionSize="1000000">
        <readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="16384" maxNameTableCharCount="16384" />
      </binaryMessageEncoding>          
      <windowsStreamSecurity protectionLevel="EncryptAndSign"/>

      <tcpTransport portSharingEnabled="false" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"   />
    </binding>
</customBinding>

当我的客户端是普通的c#控制台应用程序和使用频道死亡创建的代理时,一切正常。

        var tcpBinding = new CustomBinding();

        tcpBinding.Elements.Add(new BinaryMessageEncodingBindingElement());

        var windowsStreamSecurityBindingElement=new WindowsStreamSecurityBindingElement();
        windowsStreamSecurityBindingElement.ProtectionLevel= System.Net.Security.ProtectionLevel.EncryptAndSign;

        tcpBinding.Elements.Add(windowsStreamSecurityBindingElement);


        tcpBinding.Elements.Add(new TcpTransportBindingElement { MaxReceivedMessageSize = int.MaxValue, MaxBufferSize = int.MaxValue });
        tcpBinding.ReceiveTimeout = new TimeSpan(6, 0, 0);
        tcpBinding.SendTimeout = new TimeSpan(0, 30, 0);

        tcpBinding.ReceiveTimeout = TimeSpan.FromDays(1);
        var proxy = new ChannelFactoryServiceWrapper<IHello>(@"net.tcp://XYZ.globaltest.ABC.com:5580/Hello/tcp", tcpBinding).Channel;

        var ping = proxy.Ping();

在客户端(Silverlight 5)上我使用相同的上面一段代码但是它给出了WindowsStreamSecurityBindingElement is not available in Silverlight 5以来的编译时错误。

请告诉我任何替代方案。

0 个答案:

没有答案