zoukankan      html  css  js  c++  java
  • WCF NetTcpBinding Transport安全模式(1)NetTcpSecurity定义

    WCF NetTcpBinding Transport安全模式(1)NetTcpSecurity定义

    默认情况下,NetTcpBinding会生成一个运行时通信堆栈,该堆栈使用传输安全。

    NetTcpBinding类共有四个构造函数,分别如下:

    q  NetTcpBinding()。初始化NetTcpBinding新实例。

    q  NetTcpBinding(SecurityMode)。用所使用指定安全类型初始化NetTcpBinding新实例。

    q  NetTcpBinding(String)。使用指定配置名称初始化NetTcpBinding新实例。

    q  NetTcpBinding(SecurityMode, Boolean)用所使用指定安全类型和一个指示是否显式启用安全会话值来初始化NetTcpBinding新实例。

    NetTcpBinding类有一个类型为NetTcpSecurity属性,名为SecurityNetTcpSecurity指定用NetTcpBinding配置终结点所使用传输级安全性和消息级安全性类型。代码清单11-8NetTcpSecurity定义(部分成员)。

    代码清单11-8   NetTcpSecurity定义

    public sealed class NetTcpSecurity

    {

        // Fields

        internal const SecurityMode DefaultMode = SecurityMode.Transport;

        // Methods

        public NetTcpSecurity();

      

        public MessageSecurityOverTcp Message {get; set; }

        public SecurityMode Mode { get; set; }

        public TcpTransportSecurity Transport { get; set; }

    }

    从以上代码可以知道,NetTcpSecurityNetTcpBinding设置安全模式,并根据安全模式指定传输和消息安全细节。同时,可以看到默认情况下,NetTcpSecurityNetTcpBinding设置传输安全类型为Transport。若安全类型为Transport,那么需要设置TcpTransportSecurity属性值,TcpTransportSecurity定义如代码清单11-9所示。

    代码清单11-9     TcpTransportSecurity定义(部分代码)

    public sealed class TcpTransportSecurity

    {

        internal const TcpClientCredentialType DefaultClientCredentialType = TcpClientCredentialType.Windows;

        internal const ProtectionLevel DefaultProtectionLevel = ProtectionLevel.EncryptAndSign;

     

        [DefaultValue(1)]

        public TcpClientCredentialType ClientCredentialType {  get; set; }

        public ExtendedProtectionPolicy ExtendedProtectionPolicy {  get; set; }

        [DefaultValue(2)]

        public ProtectionLevelProtectionLevel { get; set; }

    }

    以上代码公开了TcpTransportSecurity三个属性,其中ClientCredentialType属性用来获取或设置用于身份验证客户端凭据类型;ExtendedProtectionPolicy属性用来获取或设置 TCP 传输扩展保护策略;ProtectionLevel用来设置保护级别。在默认情况下,客户端凭据类型设置为Windows,保护级别为EncryptAndSign

    下面的系列博文通过实例来探究NetTcpBinding安全配置。

     ---------------------------------------注:本文部分内容改编自《.NET 安全揭秘》

     


    作者:玄魂
    出处:http://www.cnblogs.com/xuanhun/
    原文链接:http://www.cnblogs.com/xuanhun/ 更多内容,请访问我的个人站点 对编程,安全感兴趣的,加qq群:hacking-1群:303242737,hacking-2群:147098303,nw.js,electron交流群 313717550。
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
    关注我:关注玄魂的微信公众号

  • 相关阅读:
    Zepto跨域请求
    C语言中浮点数的比较
    IOS开源项目Telegram初试
    Java NIO初试
    ios8.0之后注册通知中心
    spring AOP的配置
    IOS学习日记-2014年10月25日
    struct框架中实体类中属性的类型错误问题
    Oracle存储过程使用DML语句问题
    跳出类似framset 嵌入式框架
  • 原文地址:https://www.cnblogs.com/xuanhun/p/2560033.html
Copyright © 2011-2022 走看看