473,804 Members | 2,986 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Downloading a file from a server that requires a digital certifica

Not sure this is the right place to ask my question, please bear with me.
After reading the question, if you think there should be a different place
let me know.

I need to automate a daily download of a file from a server that requires a
digital certificate. I installed the certificate so now, when I try to access
the server with IE, a small window pops-up telling me that the "Web site I
want to view requests identification" . I am prompted to select a digital
certificate and upon selecting the one I installed I gain access to the
remote folder and see the file that I want to downlad.
At someone's suggestion I looked at WebClient.Downl oadFile, but that
obviously fails because I am not authorized to see the content of the folder
and the method will not take me to the UI where I need to select the digital
certificate. I fact I don't even need that step. As I said, I am trying to
automate the download and there should be no human input in the process.
I guess I need to somehow indicate that I want to use the respective digital
certificate when I create the web session. Is there a way this can be
achieved with the WebClient class or I need to look at a different class /
approach?

Thanks in advance for any suggestion and pardon me if this should have gone
on a different newsgroup.

Regards,
Eddie
Jul 9 '07 #1
1 1482
I figured it out. Here is the code that almost does it:
// obtain a collection of certificates
X509Store store = new X509Store("MY", StoreLocation.C urrentUser);
store.Open(Open Flags.ReadOnly | OpenFlags.OpenE xistingOnly);
collection = (X509Certificat e2Collection)st ore.Certificate s;
fcollection =
(X509Certificat e2Collection)co llection.Find(X 509FindType.Fin dByTimeValid,
DateTime.Now, false);

// URL for my file to download
string myFile2Get = "https://www.MySecureWeb site.com/MyFile.txt";

// create the specialized Web Request object
HttpWebRequest objHttpWebReq = WebRequest.Crea te(myFile2Get) as
HttpWebRequest;

// add the collection of the certificates
objHttpWebReq.C lientCertificat es = fcollection;

// default method is GET

// get the response to my request
HttpWebResponse response = objHttpWebReq.G etResponse() as HttpWebResponse ;

// Get the stream associated with the response.
Stream receiveStream = response.GetRes ponseStream();
Encoding encode = System.Text.Enc oding.GetEncodi ng("utf-8");

// Pipes the stream to a higher level stream reader with the required
encoding format.
StreamReader readStream = new StreamReader(re ceiveStream, encode);

The problem I am facing now is not related to this question and will be the
subject of a different post on this newsgroup.

Regards everyone,
Eddie
Jul 10 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
563
by: David Fitzjarrell | last post by:
omlet@omlet.org wrote in message news:<dc6c1ff0.0406300739.5001ae2a@posting.google.com>... > fitzjarrell@cox.net (David Fitzjarrell) wrote in message news:<9711ade0.0406292055.4bfaa4fe@posting.google.com>... > > omlet@omlet.org wrote in message news:<dc6c1ff0.0406291431.ef3d9f8@posting.google.com>... > > > joel-garry@home.com (Joel Garry) wrote in message > > > > > > > > "In general, if recursive calls is greater than 4 per process, the >...
2
2877
by: Brian Madsen | last post by:
Hey guys, I am currently working on a remote file upload utility from an external server to a local server. Problems I face is: 1)the request server cannot be mapped - ie. i can't secure it by using the IP or somesuch. 2)the process is automatic, no user interaction involved.
2
1276
by: Steven | last post by:
I want my users to access my .aspx and hit a button to download a file. I tried using the a System.Net.Webclient object but instead of the file being downloaded to the users PC, its copied to the server??? Any suggestions? TIA
1
2084
by: just.starting | last post by:
Hi, My dot net client downloads files and checks for any new files time to time. The server is apache2.0.53 server. So what happens is that my file download thing works fine if I dont try to call any page from the server while downloading. If I try to call a single page while downloading a file then the page request goes time out and the server then closes the existing download stream and the client doestn't throw any exception. So many a...
3
2793
by: just.starting | last post by:
Hi, My dot net client downloads files and checks for any new files time to time. The server is apache2.0.53 server. So what happens is that my file download thing works fine if I dont try to call any page from the server while downloading. If I try to call a single page while downloading a file then the page request goes time out and the server then closes the existing download stream and the client doestn't throw any exception. So many a...
2
2776
by: Tomas Martinez | last post by:
Hi there! I'm trying to download a file in my asp.net web, but when downloading it from a Firefox browser, instead of downloading the example.exe file, it's downloading example.exe.htm. My code is the following: string localfile = MyComponent.DownloadMyExe(index); Response.ClearContent(); Response.ClearHeaders(); Response.ContentType="application/octet-stream";
35
9368
by: keerthyragavendran | last post by:
hi i'm downloading a single file using multiple threads... how can i specify a particular range of bytes alone from a single large file... for example say if i need only bytes ranging from 500000 to 3200000 of a file whose size is say 20MB... how do i request a download which starts directly at 500000th byte... thank u cheers
2
6796
by: gauravgeek | last post by:
Hi, I want to create a csv file on the fly and download it on client browser. I have all the content of csv file in a vb script variant variable. I created the csv file using textstream and FSO object. I have tried adodb streaming(using ADODB.Stream object) to download but it requires me to save the content in a csv file on the server before I can download it to client browser. This creates additional problem of file cleanup. The file...
0
1283
by: =?Utf-8?B?RWRkaWUgTGFzY3U=?= | last post by:
Hello everybody, I am struggling with this issue for a few days now. I need to create an automatic process to daily download a file from a server that requires a digital certificate. The protocol used is HTTPS. This is what I did so far: // obtain a collection of certificates X509Store store = new X509Store("MY", StoreLocation.CurrentUser); store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly); collection =...
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9579
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10578
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10332
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9152
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7620
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6853
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5522
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.