惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Schneier on Security
G
GRAHAM CLULEY
T
Threat Research - Cisco Blogs
Spread Privacy
Spread Privacy
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
NISL@THU
NISL@THU
Latest news
Latest news
N
News and Events Feed by Topic
量子位
爱范儿
爱范儿
M
MIT News - Artificial intelligence
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
GbyAI
GbyAI
A
Arctic Wolf
Google Online Security Blog
Google Online Security Blog
W
WeLiveSecurity
S
Security Affairs
Webroot Blog
Webroot Blog
B
Blog
N
Netflix TechBlog - Medium
Hugging Face - Blog
Hugging Face - Blog
I
InfoQ
博客园 - 司徒正美
H
Heimdal Security Blog
罗磊的独立博客
L
LINUX DO - 最新话题
Security Archives - TechRepublic
Security Archives - TechRepublic
博客园_首页
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
Attack and Defense Labs
Attack and Defense Labs
The Hacker News
The Hacker News
Y
Y Combinator Blog
C
CERT Recently Published Vulnerability Notes
C
Cybersecurity and Infrastructure Security Agency CISA
Cyberwarzone
Cyberwarzone
C
Cisco Blogs
V
Vulnerabilities – Threatpost
T
The Exploit Database - CXSecurity.com
博客园 - 聂微东
Microsoft Azure Blog
Microsoft Azure Blog
人人都是产品经理
人人都是产品经理
The Register - Security
The Register - Security
PCI Perspectives
PCI Perspectives
The GitHub Blog
The GitHub Blog
Jina AI
Jina AI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
O
OpenAI News
S
Security @ Cisco Blogs
Google DeepMind News
Google DeepMind News

博客园 - 蝈蝈

LAMPR Ver 1.0 发布 - 轻松搞定LAMP环境 在Windows Server下集成Apache、Tomcat和IIS Windows Workflow 学习笔记二 序语言流行度最新排行榜,C和C++正在衰落 Windows Workflow学习笔记 EAI,ESB与SOA How to Building ASP.NET AJAX Controls 使用页面Gzip压缩提速 Microsoft AJAX Library 简介 Configuration Section Designer示例 开源的内容管理系统 Windows Live Writer截屏插件 试用Windows Live Writer写博客 wcf step by step:服务的状态 wcf step by step:消息交换模式 wcf step by step之异常处理 wcf step by step:改进HelloWorld程序 wcf step by step:host服务与多次Endpoint wcf step by step之HelloWorld
wcf step by step:如何保护你的wcf服务
蝈蝈 · 2008-03-01 · via 博客园 - 蝈蝈

安全是一个永恒的话题。
通过说到安全,我们会想到认证和授权,要求登录的系统都提供了认证和授权的安全性。
wcf程序有更多的安全问题,因为消息需要跨越机器边界传递,对消息进行加密是一方面,带签名是另一种方式。通常wcf包括传输通道和消息级别的安全性。如https就是具有更高安全性的传输专用通道,消息级别包括加密和解密等。下面分别来介绍一下
一、消息级别的保护
     示例:NetTcpBinding绑定的消息加密
宿主程序和客户端的配置文件中分别增加
<system.serviceModel>
...
<bindings>
      <netTcpBinding>
        <binding name="tcpBindingConfig">
          <security mode="Message">
            <message algorithmSuite="Basic128" />
          </security>
        </binding>
      </netTcpBinding>
    </bindings>

...
</system.serviceModel>
然后修改binding=netTcpBinding的endpoint指定bindingConfiguration属性=tcpBindingConfig,这样这种绑定的消息会自动进行加密和解密。下载的示例demo中启用了trace输出,这样可以通过service trace viewer工具查看D:\winform\wcf step by step\Chapter 5\Shore.cnblogs.com.WCFHost\app_tracelog.svclog(这个地址在你本机可能需要修改)这个文件来观察消息是否真正的被加密了。

  基本BasicHttpBinding绑定的消息加密需要证书,比较麻烦,但WSHttpBinding绑定的消息加密默认就会有消息加密功能,所以只要提供一个WSHttpBinding的endpoint就OK。

二、在传输通道级别保护一个HTTP服务
     我提到过,传输通道的保护可以配置为https来增强保护,由于启用https需要证书文件,比较麻烦。暂时不演示了,后面有时间再补充吧。
三、认证与授权 
     认证和授权是基本form验证的一种有效方式,也是在web程序中用的最多的一种验证方式。wcf对认证和授权有了很好的支持,这个主题也很广泛,这里只是简单演示服务器端怎么样拿到客户端的windows用户名。更多的以后再说吧

netTcpBinding绑定
string usrName = Thread.CurrentPrincipal.Identity.Name;
就OK

下载demo