alexrainman / ModernHttpClient

ModernHttpClient
MIT License
126 stars 27 forks source link

Validate Root Certificate Public Key #79

Closed twelve-cgn closed 3 years ago

twelve-cgn commented 3 years ago

Hello, first of all thanks for the great package. It saves me a lot of time. Basically, I ended up here because we need two things:

  1. Timeouts
  2. IgnoreSLL

The standard Android implementation can do both, but iOS cannot. Now I'm using ModernHttpClient and it works.

My app uses various web servers that the user can set up himself. He also receives a specially created custom certificate from me, which I generate from a root certificate.

Is it now possible, instead of simply checking each individual custom certificate of the web server, for the root certificate? Otherwise the app would always have to be expanded dynamically.

I hope I'm not talking rubbish here because, to be honest, I don't know much about certificates.

alexrainman commented 3 years ago

Please, go to the readme of the project. You will find what you are looking for.

twelve-cgn commented 3 years ago

@alexrainman I read it twice and i know to use the Pin but we are using self-signed certificates. When i execute the sample code to get the certificate public key hash i get the following error:

'java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.'

So what I need would be a callback to "verify" the certificates myself.

Thank you for your patience

MarkLFT commented 1 year ago

@twelve-cgn Did you find a solution to verifying against a private CA? I have this exact same issue, even when using the provided sample app.

gcadmes-extron commented 1 year ago

@twelve-cgn , @MarkLFT Not sure if either of you are struggling with custom private certs, but I was able to get around the 'CertPathValidatorException' by following this example: https://www.appsloveworld.com/csharp/100/446/trust-anchor-for-certification-path-not-found-in-a-net-maui-project-trying-to

or this link

https://stackoverflow.com/questions/71047509/trust-anchor-for-certification-path-not-found-in-a-net-maui-project-trying-t

HTH