Repository navigation
fix(react-native): accept ECDSA push broker certificates on Android - #2186
Merged
Merged
Conversation
…rtificate The shim now mirrors react-native-tcp-socket on Android: its peer certificate is read through an RSA key, so an ECDSA certificate rejects, and a string ca is the only certificate trusted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ng the peer's react-native-tcp-socket builds getPeerCertificate() by casting the key to RSA, so on Android an ECDSA broker certificate failed verification and Push never connected. The native module now returns the PEM it verified, and the socket trusts that certificate alone, so a server presenting any other fails the handshake before anything is written. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…erver Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🟢 Tier S · Ready to mergeAndroid push TLS verification now returns the verified leaf certificate as PEM and pins the subsequent socket handshake to it, avoiding the peer-certificate API that fails for ECDSA keys. The React Native TLS checks and Robolectric tests were updated to cover PEM pinning and ECDSA certificates.
📂 Walkthrough · 8
Reviewed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Android Push over TLS refused every broker with an ECDSA certificate, a regression from #2166. Reported on appwrite/sdk-for-react-native#130.
#2166 compared the socket's
getPeerCertificate().fingerprint256with the certificate the native module verified. On Android, react-native-tcp-socket builds that map by casting the public key toRSAPublicKey(getModulus(),getExponent(), in every release up to the latest, 6.4.3). So an ECDSA certificate rejects, and Push never sends CONNECT.Fix
The fix no longer reads the peer certificate. It pins the certificate instead:
verifiedCertificate(host, port)still verifies the chain and the hostname (subjectAltName) as HTTPS does. It now returns the verified leaf as PEM instead of a fingerprint.tcp-streamruns that check before opening the socket, then callsconnectTLS({ ca: pem }). The library loads a stringcainto a key store holding only that certificate and uses the platformTrustManagerFactory. A server presenting any other certificate fails the handshake, so nothing is written or read before verification.tlsInsecureare unchanged.Tests
getPeerCertificate()rejects non-RSA keys, and a stringcais the only certificate trusted.Push TLS ECDSA certificatecheck, using a test ECDSA CA and leaf. It replacesflood while verifying, because that window no longer exists.other certificatenow pins a different certificate.PushTlsTestexpects the PEM back, and checks that a trust store holding only that PEM accepts its server and refuses another certificate from the same root.Run locally: RN
format:check,lint,analyseandcomposer lint-twigpass. All 7Push TLSchecks pass under Node against the generated SDK. The Robolectric test and the full e2e run on CI.🤖 Generated with Claude Code