SSL Communication

You might need to communicate over a secure connection. If you do, chances are that you will be using the Secure Socket Layer (SSL). The example in Listing 26.6 shows you how to make requests using SSL.

Listing 26.6. Requesting Data Through SSL
 try { WebRequest req = WebRequest.Create( “https://www.SecureServer.com” ); WebResponse result = req.GetResponse(); Stream ReceiveStream = result.GetResponseStream(); Encoding encode = System.Text.Encoding.GetEncoding( “utf-8” ); StreamReader sr = new StreamReader( ReceiveStream, encode ); Char[] ReadBuffer = new Char[256]; int nCount = sr.Read( ReadBuffer, 0, 256 ); while( nCount > 0 ) { String str = new String( ReadBuffer, 0, nCount ); nCount = sr.Read( ReadBuffer, 0, 256 ); } } catch( ...

Get Special Edition Using® Microsoft® ASP.NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.