Consuming Webservice via https

J

Jens Mander

Hi and sorry for the heavy crossposting (fu2 mpdf)!

As you might have gotten out of the subject line, my application tries to
consume a webservice that's being connected to via https. This works fine
when I use a windows forms app. Trying the same from within an asp.net app
fails. As far as I can tell this is due to the lack of an installed client
certificate for the ASPNET windows user account. The certificate I use is
available as X.509 (.cer) and as PKCS #7 (.p7b). On MSDN I read an article
that tells how to install an PKCS #12 certificate (.pfx) into the machines
certificate store.

My question is now: How can I connect to the webservice using the
certificate I got?

Any answer is appreciated.

Regards!
 
G

Guest

You can use something like this:

// Load the client certificate from a file.
X509Certificate x509 = X509Certificate.CreateFromCertFile(@"c:\user.cer");

// Add the client certificate to the ClientCertificates property of the
proxy class.
webservice.ClientCertificates.Add(x509);


Regards,
Catalin
 
J

Jens Mander

My question is now: How can I connect to the webservice using the
certificate I got?

In the end it was all about accepting the server certificate by setting
System.Net.ServicePointManager.CertificatePolicy to an all certificates
accepting class that implements
ICertificatePolicy...

It didn't work the first time because of proxy problems. When I tried it on
the production server, it worked fine.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,783
Latest member
RickeyDort

Latest Threads

Top