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的属性,名为Security。NetTcpSecurity指定用NetTcpBinding配置的终结点所使用的传输级安全性和消息级安全性的类型。代码清单11-8是NetTcpSecurity的定义(部分成员)。
代码清单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; }
}
从以上代码可以知道,NetTcpSecurity为NetTcpBinding设置安全模式,并根据安全模式指定传输和消息安全细节。同时,可以看到默认情况下,NetTcpSecurity为NetTcpBinding设置的传输安全类型为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。
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
关注我:
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)