-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Maui -Android certificate pinning using network-security-config ignore incorrect pin #107695
Comments
Hi I'm an AI powered bot that finds similar issues based off the issue title. Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you! Open similar issues:
Closed similar issues:
|
@DmitryNikiforovCoherent Could you share us a repo, I'd like to verify it. |
We have the thumbprint in app config and use Is there a reason certificate pinning has been special cased into a separate config file etc.? |
@QianaJiao try to prepare demo soon. Just one note:
Base 64 pin I receive from ssllabs for my host |
Thank you for your reply. I will continue to investigate after I get your demo.
Here are some documents that may also be useful to you |
@QianaJiao |
I can repro this issue on both Android and iOS. No matter which |
@QianaJiao Sorry, on ios I haven't added ssl pinning, just on android(As ios works correct for me, haven't touched in demo). On android have you checked both button clicks? |
@jonathanpeppers is this Android or even runtime? |
There is a bit of confusion on this thread, so I'm not sure I follow what the problem is. Is there a sample that displays a problem? One note:
@simonrozsival might be able to help, if we think there is a runtime issue here. |
Tagging subscribers to this area: @dotnet/ncl |
Tagging subscribers to 'arch-android': @vitek-karas, @simonrozsival, @steveisok, @akoeplinger |
Tagging subscribers to this area: @dotnet/ncl, @bartonjs, @vcsjones |
In demo I used HttpClient Implementation: Managed(HttpClientHandler) Both SslClientAuthenticationOptions.RemoteCertificateValidationCallback and HttpClientHandler.ServerCertificateCustomValidationCallback called, if make a request via them Demo attached in this comment |
@DmitryNikiforovCoherent thanks for reporting this issue. I looked into it today and I think I have a rough idea where the problems in both the Currently the only workaround is to manually check the certificate hash in the |
…_config.xml` (#9302) Related to dotnet/runtime#107695 When `<domain-config ...>` is used in `network_security_config.xml` then all calls to `_internalTrustManager.CheckServerTrusted (javaChain, authType);` will throw an exception and we will always pass `SslPolicyErrors.RemoteCertificateChainErrors` to the custom server certificate validation callback. To fix this, it is necessary to use hostname-specific certificate check via `X509TrustManagerExtensions`.
Description
Added ssl pinning using network-security-config
For test change one letter of base 64 pin, but SslClientAuthenticationOptions.RemoteCertificateValidationCallback still pass SslPolicyErrors.None
Steps to Reproduce
Added network_security_config.xml as AndroidResource
<network-security-config> <domain-config> <domain includeSubdomains="true">{host}</domain> <pin-set expiration="2025-03-21"> <pin digest="SHA-256">pin</pin> </pin-set> </domain-config> </network-security-config>
Added SocketsHttpHandler with SslClientAuthenticationOptions.RemoteCertificateValidationCallback
I expect, that if I change base64 pin to incorrect, RemoteCertificateValidationCallback will be called with RemoteCertificateNameMismatch, as for IOS, but receive SslPolicyErrors.None
Link to public reproduction project repository
No response
Version with bug
8.0.70 SR7
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Any android version
Did you find any workaround?
No response
Relevant log output
No response
The text was updated successfully, but these errors were encountered: