Digest Authentication with RestSharp

Since RestSharp does not provide an authenticator for Digest Authentication, I simple wrote one that works for me.

Usage

var client =
    new RestClient(@"http://yourserver.com/api")
    {
        Authenticator = new DigestAuthenticator(userName, password)
    };

Implementation

The class is rather simple:

public class DigestAuthenticator : 
    IAuthenticator
{
    private readonly string _user;
    private readonly string _pass;

    public DigestAuthenticator(string user, string pass)
    {
        _user = user;
        _pass = pass;
    }

    public void Authenticate(
        IRestClient client, IRestRequest request)
    {
        request.Credentials = new NetworkCredential(_user, _pass);
    }
}

Enjoy! 🙂

Web Debugging Proxy

Wow, cooles Tool, dieser Charles:

Charles is a web proxy (HTTP Proxy / HTTP Monitor) that runs on your own computer. Your web browser (or any other Internet application) is then configured to access the Internet through Charles, and Charles is then able to record and display for you all of the data that is sent and received.

Und der kann sogar SSL-Verbindungen als Klartext darstellen:

Charles can be used as a man-in-the-middle HTTPS proxy, enabling you to view in plain text the communication between web browser and SSL web server.

Charles does this by becoming a man-in-the-middle. Instead of your browser seeing the server’s certificate, Charles dynamically generates a certificate for the server and signs it with its own root certificate (the Charles CA Certificate). Charles receives the server’s certificate, while your browser receives Charles’s certificate. Therefore you will see a security warning, indicating that the root authority is not trusted. If you add the Charles CA Certificate to your trusted certificates you will no longer see any warnings – see below for how to do this.

Hammer, so gehen bestimmt auch Geheimdienste vor!

Kostenloser Windows-HTTP-Proxy-Server

Kleiner Tipp, wenn Ihr mal zum Testen einen HTTP-Proxyserver benötigt:

CC Proxy

Dieser Proxy kann maximal 3 Benutzer unterstützen, was zum Testen ja völlig reicht. In meinem Fall habe ich ihn direkt auf meinem Test-Windows-7 in einer Vmware installiert und im Internet Explorer dann den Proxy angegeben.

Testumgebung

Um den Proxy einfach für lokale Tests zu konfigurieren, wie folgt vorgehen:

proxy-01
proxy-02
proxy-03

In Internet Explorer dann in den Einstellungen:

proxy-04