HTTPS & Digest Authentication

戏子无情 提交于 2019-12-25 10:53:32

问题


How to implement HTTPS with Digest Authentication in C#.Net? as per msdn, credential class has no support for SSL.. so how can we implement authentication? my code works with basic authentication but gives error with digest..


回答1:


You can specify the type of credential when creating a credential in the CredentialCache, which is used for WebClients and WebRequests. So, for example, to populate the CredentialCache to try Digest auth you could use

CredentialCache cache = new CredentialCache();
Uri prefix = new Uri ("http://www.example.com");
cache.Add (prefix, "Digest",  new NetworkCredential ("username", "passwd"));

WebClient wc = new WebClient();
wc.Credentials = cache;

As digest authentication is dependant on the destination URL, and the realm if it specifies one you do need to get those right.




回答2:


You are trying to combine things that are usually considered to be alternatives to each other. HTTP Digest Authentication encrypts user credentials using MD5, which is not considered to be secure enough nowadays.

So, the message here is: use HTTPS with basic authentication.



来源:https://stackoverflow.com/questions/1970465/https-digest-authentication

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!