Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

untrusted and selfsigned certificate to WCF client (Android, 8.1)? #5706

Open
svetislavvuksanovic opened this issue Dec 5, 2024 · 1 comment

Comments

@svetislavvuksanovic
Copy link

Hi,
I'm having hard time setting untrusted selfsigned certificate to WCF client on Android; on call there is null exception in HTTPSChannelFactory (SetCertificate, list is not accepting null, certificate probably = null); certificate is set to store and retrieved ok; cert is set to channellfactory ok; is chain.build validation (X509CertificateValidator )maybe striping my cert? any chance to avoid validation? ITrustManager implementation is not getting anything to work with so problem is before that; I suppose that same problem is present on server side of things; thanks!

@mconnew
Copy link
Member

mconnew commented Dec 5, 2024

When you use SetCertificate, it uses X509Store to look for the certificate installed in the cert store. I don't know how that functionality works on Android, eg how StoreLocation and StoreName map to how Android handles certificates. If you have the X509Certificate instance already, then just set it directly on ClientCredentials.ClientCertificate.Certificate. The certificate is set on the HttpClientHandler instance.

The X509CertificateValidator is used to validate the certificate that the server is using. There's a frustrating security feature on Android where it rejects self signed certificates from services. They must be signed by a trusted root certificate, and now you can't install your own root certificates if targeting a recent Android API version. So if you are talking about your service certificate being self signed, the underlying native Android implementation of HttpClientHandler won't even call a certificate validator if it doesn't pass the chain build with a valid root certificate that it does itself. It will just fail the request and there's nothing you can do about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants