This documentation is archived and is not being maintained.
Using Secure Sockets Layer
.NET Framework 2.0
Theclasses use the Secure Sockets Layer (SSL) to encrypt the connection for several network protocols.
For http connections, theand classes use SSL to communicate with web hosts that support SSL. The decision to use SSL is made by the WebRequest class, based on the URI it is given. If the URI begins with "https:", SSL is used; if the URI begins with "http:", an unencrypted connection is used.
To use SSL with File Transfer Protocol (FTP), set theproperty to true prior to calling . Similarly, to use SSL with Simple Mail Transport Protocol (SMTP), set the property to true prior to sending the e-mail.
Theclass provides a stream-based abstraction for SSL, and offers many ways to configure the SSL handshake.
String MyURI = "https://www.contoso.com/"; WebRequest WReq = WebRequest.Create(MyURI); String serverUri = "ftp://ftp.contoso.com/file.txt" FtpWebRequest request = (FtpWebRequest)WebRequest.Create(serverUri); request.EnableSsl = true; request.Method = WebRequestMethods.Ftp.DeleteFile; FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Compiling the Code
This example requires:
References to the System.Net namespace.