Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

387
Views
How to use a self-signed SSL certificate without ServicePointManager.ServerCertificateValidationCallback?

I have an HttpClient which uses a self-signed SSL certificate which is saved on the client computer as a .cer file. To validate the certificate, I use ServicePointManager.ServerCertificateValidationCallback in the following way (not my actual code, just the essence):

ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, errors) =>
{
    if (errors == SslPolicyErrors.None) return true;
    if (cert.Subject == "CN=CertificateCommonName")
        return CertificatesMatch(cert, GetSavedCertificateFromFile());
    else
        return false;
};

However, I noticed that this function only gets called once for any certificate per process (more exactly per AppDomain, probably), which means that once a certificate has been validated, it is stored somewhere in a "valid certificates cache". Is there a way I can simply add my saved certificate to that cache?

I wish I could simply use an HttpClientHandler with my HttpClient and add the certificate to the ClientCertificates property, however I am targeting .NET Framework 4.5, and that feature is only available from .NET Framework 4.7.1, so that is not an option.

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!