Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HttpRequestMessage and Digest Authentication

Is there any built-in function to associate a digest authentication with an HttpRequestMessage in winrt ? Or do I have to use an other class in order to perfom this task ?

Thanks.

like image 270
Gregoire Avatar asked May 18 '12 18:05

Gregoire


People also ask

How does digest authentication work?

Unlike the plaintext scheme used by Basic authentication, Digest authentication has the client send a hash of the client's information over the communication channel, therefore the client's user name and password are never sent over the network.

What is nonce in Digest authentication?

Client nonce was introduced in RFC 2617, which allows the client to prevent chosen-plaintext attacks, such as rainbow tables that could otherwise threaten digest authentication schemes. Server nonce is allowed to contain timestamps.


1 Answers

I'm using the HttpClient for an HttpRequest Message. The HttpClient constructor accepts a HttpClientHandler, which accepts as Credentials property an instance of CredentialCache. A CredentialCache should be able to work with digest authentication.

Code should be like:

var credCache = new CredentialCache();
credCache.Add(new Uri("http://.com/"),"Digest", new NetworkCredential(UserName,SecurelyStoredPassword,Domain));
var httpClient = new HttpClient( new HttpClientHandler { Credentials = credCache});
var answer = httpClient.GetAsync(new Uri("http://request.Uri"));
like image 64
Jan K. Avatar answered Sep 18 '22 17:09

Jan K.