本文发表在 rolia.net 枫下论坛ssl use private/public key pair to pass a encryption key between them so the key is only known by the server and client.
server certificate is just a way to tell you this server is trusted by some wellknown institution, so you can trust it too.
to download a file from https, it can be as easy as
WebClient client = new WebClient ();
client.DownloadFile("https://www.paypal.com/en_US/i/logo/paypal_logo.gif", "1.gif");
try
{
client.DownloadFile("https://64.4.241.33/en_US/i/logo/paypal_logo.gif", "2.gif");
}
catch (Exception e)
{
string str = e.ToString();
}
see the second try failed, cause the server's certificate is not match.
But now I guess what you want might be more complicated: login to a https site with username and password then download a file.
Then you have to go back to httpwebrequest, send a request to ssl server with POST username and password, analyse the result and find out something like SESSIONKEY or cookie, then send back the server another request with the session key ( to let the server know you are a login user) to download the file.
you need to understand http protocol to do it.更多精彩文章及讨论,请光临枫下论坛 rolia.net
server certificate is just a way to tell you this server is trusted by some wellknown institution, so you can trust it too.
to download a file from https, it can be as easy as
WebClient client = new WebClient ();
client.DownloadFile("https://www.paypal.com/en_US/i/logo/paypal_logo.gif", "1.gif");
try
{
client.DownloadFile("https://64.4.241.33/en_US/i/logo/paypal_logo.gif", "2.gif");
}
catch (Exception e)
{
string str = e.ToString();
}
see the second try failed, cause the server's certificate is not match.
But now I guess what you want might be more complicated: login to a https site with username and password then download a file.
Then you have to go back to httpwebrequest, send a request to ssl server with POST username and password, analyse the result and find out something like SESSIONKEY or cookie, then send back the server another request with the session key ( to let the server know you are a login user) to download the file.
you need to understand http protocol to do it.更多精彩文章及讨论,请光临枫下论坛 rolia.net