Treat APNs team/key IDs as secrets so they can change atomically with the key itself

This commit is contained in:
Jon Chambers 2023-10-12 12:23:26 -04:00 committed by Jon Chambers
parent 207ae6129b
commit f2a3b8dba4
4 changed files with 7 additions and 5 deletions

View File

@ -46,6 +46,8 @@ gcpAttachments.rsaSigningKey: |
AAAAAAAA
-----END PRIVATE KEY-----
apn.teamId: team-id
apn.keyId: key-id
apn.signingKey: |
-----BEGIN PRIVATE KEY-----
ABCDEFGHIJKLMNOPQRSTUVWXYZ/0123456789+abcdefghijklmnopqrstuvwxyz

View File

@ -208,8 +208,8 @@ accountDatabaseCrawler:
apn: # Apple Push Notifications configuration
sandbox: true
bundleId: com.example.textsecuregcm
keyId: unset
teamId: unset
keyId: secret://apn.keyId
teamId: secret://apn.teamId
signingKey: secret://apn.signingKey
fcm: # FCM configuration

View File

@ -9,8 +9,8 @@ import javax.validation.constraints.NotNull;
import org.whispersystems.textsecuregcm.configuration.secrets.SecretString;
public record ApnConfiguration(@NotBlank String teamId,
@NotBlank String keyId,
public record ApnConfiguration(@NotNull SecretString teamId,
@NotNull SecretString keyId,
@NotNull SecretString signingKey,
@NotBlank String bundleId,
boolean sandbox) {

View File

@ -64,7 +64,7 @@ public class APNSender implements Managed, PushNotificationSender {
this.bundleId = configuration.bundleId();
this.apnsClient = new ApnsClientBuilder().setSigningKey(
ApnsSigningKey.loadFromInputStream(new ByteArrayInputStream(configuration.signingKey().value().getBytes()),
configuration.teamId(), configuration.keyId()))
configuration.teamId().value(), configuration.keyId().value()))
.setTrustedServerCertificateChain(getClass().getResourceAsStream(APNS_CA_FILENAME))
.setApnsServer(configuration.sandbox() ? ApnsClientBuilder.DEVELOPMENT_APNS_HOST : ApnsClientBuilder.PRODUCTION_APNS_HOST)
.build();