Skip to content

Fix JWT encoding, null safety, and code quality issues#101

Closed
andrei-m-code wants to merge 2 commits intomasterfrom
fix/code-quality-improvements
Closed

Fix JWT encoding, null safety, and code quality issues#101
andrei-m-code wants to merge 2 commits intomasterfrom
fix/code-quality-improvements

Conversation

@andrei-m-code
Copy link
Copy Markdown
Owner

@andrei-m-code andrei-m-code commented Feb 25, 2026

Summary

  • Fix Base64URL encoding in both ApnSender and FirebaseSender — was using plain Base64 instead of URL-safe Base64 (RFC 7617: replace +-, /_, strip = padding). This could cause malformed JWTs and authentication failures with Apple/Google.
  • Fix NullReferenceException in ApnSender error handling — Deserialize<ApnsError>(content).Reason now uses null-conditional operator to handle unexpected error formats from Apple.
  • Fix static token cache key collision — cache key now includes P8PrivateKeyId so multiple ApnSender instances with the same bundle ID but different credentials don't share tokens.
  • Add device token validation in ApnSender.SendAsync() — throws ArgumentException on null/empty tokens instead of sending invalid requests to Apple.
  • Propagate CancellationToken through FirebaseSender.GetJwtTokenAsync() — the token was accepted by SendAsync but not passed to internal HTTP calls.
  • Remove infinite loop in CorePush.Tester and log the response.
  • Remove unused System.IdentityModel.Tokens.Jwt dependency from CorePush.Tester.

Test plan

  • Verify solution builds cleanly (dotnet build CorePush.sln)
  • Test APN push notification sending with valid credentials
  • Test Firebase push notification sending with valid credentials
  • Verify cancellation works in Firebase sender

andrei-m-code and others added 2 commits February 25, 2026 14:47
…is CI

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix Base64URL encoding in ApnSender and FirebaseSender (RFC 7617)
- Fix potential NullReferenceException in ApnSender error handling
- Fix static token cache key collision by including key ID
- Add device token validation in ApnSender.SendAsync
- Propagate CancellationToken in FirebaseSender.GetJwtTokenAsync
- Remove infinite loop in CorePush.Tester
- Remove unused System.IdentityModel.Tokens.Jwt dependency
@andrei-m-code
Copy link
Copy Markdown
Owner Author

Superseded by a more comprehensive PR that also removes BouncyCastle and upgrades to .NET 10

@andrei-m-code andrei-m-code deleted the fix/code-quality-improvements branch March 23, 2026 23:07
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

Successfully merging this pull request may close these issues.

1 participant