This chapter showed you how to use HTTP security mechanisms. HTTP has two built-in security mechanisms. Firstly, HTTP supports encryption through HTTPS. Secondly, HTTP provides authentication, which requires users to identify themselves.
This chapter includes two recipes. These two recipes will demonstrate the following:
Determining if a URL uses HTTPS, and
Using HTTP authentication
The first recipe will introduce you to some of the things that can be done with the HttpWebRequest class. The second recipe shows how to access a site that uses HTTP authentication.
As you saw earlier in this chapter, HTTPS allows you to determine that the web server you are connecting to is what it claims to be. HTTP authentication provides the other side of this verification. HTTP authentication allows the server to determine that the web user is who they say that they are.
HTTPS is implemented as a protocol just like HTTP. Whereas an HTTP URL starts with “http”, an HTTPS protocol starts with “https”. For example, the following URL specifies a secure page on the HTTP recipe site:
It is important to understand that a URL starting with “https” is not just a secure version of the same URL beginning with an “http”. Consider the following URL: