2012-09-11 20 views
0

我有一个ASP.NET Web窗体应用程序,我需要模拟一个帐户以连接到一个Web服务。应用程序始终与同一个帐户连接,并且必须加密。模拟并加密用户帐户以从ASP.NET应用程序调用Web服务

客户是MyWebServiceClient()我的代码是:

MyWebService.MyWebServiceClient client = new MyWebService.MyWebServiceClient(); 

client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation; 
client.ClientCredentials.Windows.ClientCredential = new NetworkCredential(username, password, domain); 

而且它完美的作品。问题是如何加密这些数据。是否有可能在Web服务绑定内的web.config中执行它?

<security mode="TransportCredentialOnly"> 
    transport clientCredentialType="Windows" realm="" /> 
<security> 

如果是这样的话,我该如何从代码中检索它们?谢谢

+0

你想加密什么? webconfig中的凭据?您的应用程序和webservice之间的流量? – Oscar

+0

谢谢!我想加密webconfig中的凭证 – CiccioMiami

回答

1

将您的凭据添加到应用程序设置部分。然后使用aspnet_regis工具

How to encrypt one entry in web.config

http://www.dotnetprofessional.com/blog/post/2008/03/03/Encrypt-sections-of-WebConfig-or-AppConfig.aspx

问候asere加密部分。

+0

谢谢!我应该将web.config的安全部分作为客户端凭证放入什么内容? – CiccioMiami

+1

您的ws被配置为接收的那种客户端凭证... http://msdn.microsoft.com/en-us/library/system.servicemodel.httptransportsecurity.clientcredentialtype.aspx – Oscar

相关问题