C # HTTPS Client tool methods for obtaining certificates

Source: Internet
Author: User

1. Import the certificate into your PC



2. Obtaining a Certificate

[CSharp]View PlainCopyprint?
  1. Private static X509Certificate2 getsentosacertificate ()
  2. {
  3. X509store Usercastore = new X509store (storename.my, storelocation.localmachine);
  4. Try
  5. {
  6. Usercastore.open (openflags.readonly);
  7. X509Certificate2Collection Certificatesinstore = usercastore.certificates;
  8. X509Certificate2Collection Findresult = Certificatesinstore.find (X509findtype.findbysubjectname, "*.  Sentosa.com.sg ", true);
  9. X509Certificate2 clientcertificate = null;
  10. if (Findresult.count = = 1)
  11. {
  12. ClientCertificate = findresult[0];
  13. }
  14. Else
  15. {
  16. throw New Exception ("Unable to locate the correct client certificate.");
  17. }
  18. return clientcertificate;
  19. }
  20. Catch
  21. {
  22. throw;
  23. }
  24. finally
  25. {
  26. Usercastore.close ();
  27. }
  28. }


3. Attach the certificate to the HTTP request

http://www.woaipu.com/shops/zuzhuan/61406
Http://www.znds.com/tv-967956-1-1.html
Http://www.znds.com/tv-967958-1-1.html

C # HTTPS Client tool methods for obtaining certificates

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.