473,399 Members | 3,401 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

C# DLL - Used in VB Project - Certificate Store gathering certs for use in httpwebrequest

Joe
Hello,
I'm currently using a C# class library which is also
converted quickly to a console app by adding a MAIN and adjusting the
building configuration. I'm using this page as a reference to the
code. http://support.microsoft.com/kb/895971 .

I am using the CryptoAPI calls instead of a *.cer file. The only
reason i'm using this method instead is because now a large project of
mine no longer will work properly when using an exported cer file.
This is your typical hit a webservice with a certificate and process
some XML. I put together the C# classlibrary page and created a main
to run some tests on the c# code. Everything works Perfect when
running the console app and obtaining the certificate from the store
and then hitting the URL. BUT when i include the DLL that was created
from the c# class library in a VB project and attempt to run the exact
same code it fails. The line that is causing all the problems is the
function from the crypt32.dll.

currentCertContext = CertEnumCertificatesInStore(storeHandle,
(IntPtr)0);

This line in my C# console app works just fine and returns a HANDLE as
its supposed to thats not zero. But when running thru the exact same
code but thru the VB project calling the objects from the DLL the
currentCertContext is always 0. Causing this process to not gather
any certificates. I don't get how the code alone in its own console
app works just fine but when its included as a DLL in a vb site it
doesn't work. Has anyone ran into anything like this ever? Or heard
anything about this occuring? I can provide more information if
needed. As i debug and walk through the VB app it goes into the DLL
(even opens up the C# page and goes thru the same process) But that
one line isn't producing a proper intptr handle. Any information
would be greatly appreciated.

May 10 '07 #1
1 5884
Joe
On May 10, 1:01 pm, Joe <eterna...@gmail.comwrote:
Hello,
I'm currently using a C# class library which is also
converted quickly to a console app by adding a MAIN and adjusting the
building configuration. I'm using this page as a reference to the
code.http://support.microsoft.com/kb/895971.

I am using the CryptoAPI calls instead of a *.cer file. The only
reason i'm using this method instead is because now a large project of
mine no longer will work properly when using an exported cer file.
This is your typical hit a webservice with a certificate and process
some XML. I put together the C# classlibrary page and created a main
to run some tests on the c# code. Everything works Perfect when
running the console app and obtaining the certificate from the store
and then hitting the URL. BUT when i include the DLL that was created
from the c# class library in a VB project and attempt to run the exact
same code it fails. The line that is causing all the problems is the
function from the crypt32.dll.

currentCertContext = CertEnumCertificatesInStore(storeHandle,
(IntPtr)0);

This line in my C# console app works just fine and returns a HANDLE as
its supposed to thats not zero. But when running thru the exact same
code but thru the VB project calling the objects from the DLL the
currentCertContext is always 0. Causing this process to not gather
any certificates. I don't get how the code alone in its own console
app works just fine but when its included as a DLL in a vb site it
doesn't work. Has anyone ran into anything like this ever? Or heard
anything about this occuring? I can provide more information if
needed. As i debug and walk through the VB app it goes into the DLL
(even opens up the C# page and goes thru the same process) But that
one line isn't producing a proper intptr handle. Any information
would be greatly appreciated.
UPDATE****************
I've ran into a sticky situation. I currently have a ASP.NET
web project, this project uses webservices to receive XML from various
locations. One of the locations requires a x509 certificate in order
for it to work properly. All was good until they sent us a new
certificate two weeks ago. Now using the export *.cer method I can no
longer hit there webservice. They tell me that anything thats going
wrong is on my end. After much playing around with it, I decided to
try the CryptoAPI way instead, which would be just to hit the actual
certificate store and gather all the certs in a collection and pull
the one that i need directly from it and apply it to the
httpwebrequest object. I wrote up a small C# console app, this app is
very basic its just going to the store gathering the certs then
applying the cert to a webrequest object then hitting the URL. As a
console app this works just fine. I adjusted my console app to become
a compiled DLL. I then add a reference to my VB project of that DLL.
But now I cannot grab any certificates from any store. I believe this
has to do with the fact that the console app is running under a
different user context than my vb.net web project. My question would
be how can get my ASP.NET web project to actually have access to the
certificate store? I've followed along on http://msdn2.microsoft.com/en-us/library/aa302408.aspx
this page numerous times giving permission to the ASPNET/
NetworkService/Administrator users to that particular certificate.
but nothing will access it. Its currently residing on both my
certificates of my local user as well as the certificates of my local
computer. Is there anyway to get this to work properly? The code
that is being based off of is from the microsoft page that explains
the two ways to access the certificate. The *.cer way and the
CryptoAPI way. Any information would be greatly appreciated.

May 10 '07 #2

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

Similar topics

1
by: Jeff Fulcer | last post by:
I am trying to do a get/post with a certificate to another server to gather information. I was provided with an ASP example that I am able to get my results fine with, but when I try it in .NET,...
2
by: Jonathan Wax | last post by:
Hi, I spent the last week looking for an answer to the following question: How can you upload an xml file to an HTTPS server with a specific certificate. Basically doing the same as this html...
0
by: NRao | last post by:
Hello Everbody, I have a class lib which is accessing a .aspx on web through httpwebrequest and sending xml through post method. Server people provided me a .cer file. I am adding that...
0
by: Jojo1771 | last post by:
I am baffled, I have a web service doing a ssl connection to a website using ssl and a certificate that came to me in a p12 format. This code worked 100% in vb.net app but fails to work in...
2
by: jens Jensen | last post by:
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(ConfigurationManager.AppSettings); req.Proxy = new System.Net.WebProxy(ConfigurationManager.AppSettings, true); req.ContentType =...
0
by: jens Jensen | last post by:
Hello, I'm trying to connect to a system via https. As an additional security measure, the server requires me to attach an x509 certs to my "HTTP POST" request. I get the error...
5
by: oliharvey | last post by:
hallo - I am making a web request (actually a web service call) from within my web service. this works fine under the developement web server - but fails under IIS with: anyone have any...
5
by: jitsu | last post by:
Hi all, I have a problem. I need to connect to Web Server, send a xml string (query) to it and receive another xml string (result). I have the location of the Web Server like:...
1
by: am1974po | last post by:
I have 2 applications: One is simple windows application and the other is web service. They are both on the same machine, windows server 2003 - SP2. exactly the same code in both:...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
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...

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.