2012-09-11 19 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

相關問題