Consuming Webservice via https

Discussion in 'ASP .Net Web Services' started by Jens Mander, Dec 4, 2006.

  1. Jens Mander

    Jens Mander Guest

    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!
     
    Jens Mander, Dec 4, 2006
    #1
    1. Advertising

  2. Jens Mander

    Catalin T 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


    "Jens Mander" wrote:

    > 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!
    >
    >
    >
     
    Catalin T, Dec 7, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John

    Consuming webservice

    John, Jun 22, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    360
  2. batista
    Replies:
    1
    Views:
    965
    Laurent Bugnion
    Jan 26, 2006
  3. batista
    Replies:
    0
    Views:
    587
    batista
    Jan 26, 2006
  4. Jens Mander

    Consuming Webservice via https

    Jens Mander, Dec 4, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    417
    Jens Mander
    Dec 11, 2006
  5. batista
    Replies:
    0
    Views:
    276
    batista
    Jan 26, 2006
Loading...

Share This Page