fpush-apns: add APNs token-based authentication (p8)#42
Open
infobug wants to merge 3 commits into
Open
Conversation
Add support for token-based APNs authentication as an alternative to certificate-based (p12) auth. Token-based auth uses a .p8 key file that never expires, eliminating the need for annual certificate renewal. Config now accepts either: - certFilePath + certPassword (existing p12 flow, unchanged) - keyPath + keyId + teamId (new p8 token flow) Both auth methods are fully supported and backward compatible. Existing p12 configs continue to work without modification.
5b2f29b to
2a119da
Compare
SystemTime::now().elapsed() returns the duration between two consecutive now() calls — effectively zero. Adding 4 weeks gave apns-expiration=2,419,200 (~Jan 28 1970) on every push, which APNs silently drops per Apple's documented behavior for past-timestamp expirations (see Apple Developer Forums thread #708937). Result: every push that did not deliver immediately on first attempt was discarded by APNs with no error feedback to fpush. Devices that were briefly offline / sleeping / handing off cellular missed pushes entirely with no log evidence anywhere in the pipeline. Replace with SystemTime::now().duration_since(UNIX_EPOCH), which returns the current unix timestamp. Adding 4 weeks now gives a correctly-future expiration so APNs holds and retries deliveries per its normal store-and-forward semantics.
…und)
Two changes to align the APNs payload with Signal's
APN_NSE_NOTIFICATION_PAYLOAD:
1. Add apns-collapse-id "incoming-message". When the NSE fails to
post a user-visible notification (the fallback case) and several
pushes arrive while the device is locked, the fallback alerts
collapse to one entry on the lock screen instead of stacking N
copies of "New Message". Per-conversation notifications NSE posts
via UNUserNotificationCenter use their own identifiers and are
unaffected.
2. Drop the default sound from the APNs payload. NSE-posted
notifications carry the user's chosen sound from app settings;
when NSE fails and the fallback alert is what surfaces, match
Signal's silent-failure UX rather than inconsistent audio cues.
Reference: signalapp/Signal-Server APNSender.java —
static final String APN_NSE_NOTIFICATION_PAYLOAD = new
SimpleApnsPayloadBuilder()
.setMutableContent(true)
.setLocalizedAlertMessage("APN_Message")
.build();
apns-collapse-id: notification.urgent() ? "incoming-message" : null
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.
Summary
.p8key file that never expires, eliminating annual certificate renewalConfiguration
Either auth method can be used by providing the appropriate fields:
Certificate-based (existing, unchanged):
Token-based (new):
Implementation
config.rs: MadecertFilePath/certPasswordoptional, addedkeyPath/keyId/teamIdfields, addedApnsAuthenum to express the two auth modespush.rs: Added a second init path usingClient::token()from the existinga2crate (which already supports token auth), with clear error messaging if neither auth method is configuredTest plan