Skip to content

Commit a638f19

Browse files
committed
Update MPNS to use APNs AuthKey instead of certificates
1 parent 752d8f7 commit a638f19

15 files changed

+76
-91
lines changed
Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,55 @@
11
---
22
title: "iOS push notifications"
33
heading: "iOS push notifications"
4-
description: "Push notifications on iOS are managed and dispatched using Apple’s Push Notification Service. Learn how to use this service with Mattermost."
5-
date: 2015-05-20T11:35:32-04:00
4+
description: "Learn how to generate an APNs Auth Key for iOS push notifications."
5+
date: 2025-09-19T08:44:00+08:00
66
weight: 2
77
aliases:
88
- /contribute/mobile/push-notifications/ios
99
---
1010

11-
Push notifications on iOS are managed and dispatched using {{< newtabref href="https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/APNSOverview.html" title="Apple's Push Notification Service" >}}. You must have a **Paid Apple Developer account** to create certificates needed to send notifications using this service.
11+
## Generate APNs Auth Key
1212

13-
- Generate a Certificate from Keychain Access
14-
- Launch the **Keychain Access application** in your Mac and select **KeyChain Access -\Certificate Assistant -\Request a Certificate From a Certificate Authority...**
15-
![image](/img/mobile/ios_keychain_request_certificate.png)
13+
To deliver push notifications on iOS, you need to authenticate with **Apple Push Notification service (APNs)**.
14+
Mattermost recommends using **token-based authentication** with an APNs Auth Key (`.p8`) instead of certificates.
1615

17-
- Enter your email address in **User Email Address** and check the **"Save to disk"** option, then click **Continue**
18-
![image](/img/mobile/ios_keychain_create_cert_request.png)
19-
20-
- Save the certificate request
21-
![image](/img/mobile/ios_keychain_save_cert_request.png)
16+
---
2217

23-
- Log in to {{< newtabref href="https://developer.apple.com/account" title="Apple developer account" >}} and click **Certificates, Identifiers and Profiles**
24-
![image](/img/mobile/ios_account.png)
18+
### Prerequisites
2519

26-
- Select the plus icon to create a new certificate
27-
![image](/img/mobile/ios_new_certificate.png)
20+
- Apple Developer Program account
21+
- Registered iOS app Bundle ID with **Push Notifications** capability enabled
2822

29-
- Select a new "Apple Push Notifications service SSL (Sandbox & Production)"
30-
![image](/img/mobile/apns.png)
23+
---
3124

32-
- Choose the App ID you're generating a certificate for. Use the regular App ID for the Mattermost app, **not** for the `.NotificationService`, etc.
33-
![image](/img/mobile/choose_app_id.png)
25+
### 1. Create an APNs Auth Key
26+
27+
1. Sign in to {{< newtabref href="https://developer.apple.com/account/resources/authkeys/list" title="Apple Developer: Keys" >}}.
28+
2. Click **+** to register a new key.
29+
![Apple Developer register new key](/img/mobile/ios-register-key.png)
30+
3. **Enter a Key Name** to easily identify it later (e.g., *Mattermost Push Proxy*).
31+
![Enter key name](/img/mobile/ios-key-name.png)
32+
4. **Enable APNs** by checking the **Apple Push Notifications service (APNs)** box and click **Configure** to configure the key.
33+
![Enable APNs](/img/mobile/ios-enable-apns.png)
34+
5. On the **Configure Key** screen:
35+
- Select an **Environment**: *Sandbox*, *Production*, or *Sandbox & Production*.
36+
- Choose a **Key Restriction**: *Team Scoped (All Topics)* or *Topic Specific*.
37+
![Configure APNs key](/img/mobile/ios-configure-apns.png)
38+
- If you select *Topic Specific*, add the topics (App IDs) you want to associate.
39+
![Add topics](/img/mobile/ios-add-topics.png)
40+
6. Click **Save**, then **Continue**.
41+
7. Review the Key details and click **Register**
42+
8. Download the generated file `AuthKey_XXXXXXXXXX.p8` and store it securely.
43+
> You can only download the file once.
44+
9. Note the following values:
45+
- **Key ID** (from the Keys list)
46+
- **Team ID** (from your Apple Developer Membership)
47+
- **Bundle ID** (your app identifier, used as the APNs topic)
48+
49+
![Apple Developer key list](/img/mobile/ios-key-list.png)
3450

35-
- Choose the certificate request file created using the Keychain access in the previous section and select **Continue**.
36-
![image](/img/mobile/ios_upload_csr.png)
51+
---
3752

38-
- Download the Certificate and click **Done** to finish the process
53+
### 2. Next Steps
3954

40-
At this point, you can build the Mattermost app for iOS and use the above downloaded certificate to setup the [Mattermost Push Notification Service]({{< ref "/contribute/more-info/mobile/push-notifications/service" >}}).
55+
Once you’ve generated your APNs Auth Key and collected the Key ID, Team ID, and Bundle ID, continue to the [Push Notification Service setup]({{< ref "/contribute/more-info/mobile/push-notifications/service" >}}) page to configure the Mattermost Push Notification Service (MPNS).

site/content/contribute/more-info/mobile/push-notifications/service.md

Lines changed: 38 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Push notification service"
33
heading: "Install the Mattermost push notification service"
4-
description: "This guide focuses on installing and configuring the push notification service for Mattermost apps."
4+
description: "Learn how to configure the Mattermost Push Notification Service (MPNS) with iOS and Android credentials."
55
date: 2015-05-20T11:35:32-04:00
66
weight: 3
77
aliases:
@@ -12,25 +12,30 @@ Now that the app can receive push notifications, we need to make sure that the M
1212

1313
### Requirements
1414

15-
- A Linux box server with at least 1GB of memory.
15+
- A Linux or FreeBSD box server with at least 1GB of memory.
1616
- A copy of the {{< newtabref href="https://github.com/mattermost/mattermost-push-proxy/releases" title="Mattermost Push Notification Service" >}}.
1717
- [Custom Android and/or iOS]({{< ref "/contribute/more-info/mobile/build-your-own" >}}) Mattermost mobile apps.
18-
- Private and public keys obtained from the {{< newtabref href="https://developer.apple.com/account/ios/certificate/" title="Apple Developer Program" >}}.
19-
- A Firebase Cloud Messaging Server key obtained from the {{< newtabref href="https://console.firebase.google.com" title="Firebase Console" >}}.
18+
- An APNs Auth Key (`.p8`) obtained by following the [iOS Push Notifications guide]({{< ref "/contribute/more-info/mobile/push-notifications/ios" >}}).
19+
- A Firebase Cloud Messaging Server key obtained by following the [Android Push Notifications guide]({{< ref "/contribute/more-info/mobile/push-notifications/android" >}}).
2020

2121
## Install and upgrade
2222

2323
For the sake of making this guide simple we located the files at `/home/ubuntu/mattermost-push-proxy`. We've also elected to run the Push Notification Service as the `ubuntu` account for simplicity. We **recommend** setting up and running the service under a `mattermost-push-proxy` user account with limited permissions.
2424

25-
1. Download the Mattermost Push Notification Service (any version):
25+
1. Download the latest Mattermost Push Notification Service:
2626

27-
`wget https://github.com/mattermost/mattermost-push-proxy/releases/download/vX.X.X/mattermost-push-proxy.tar.gz` (`mattermost-push-proxy-X.X.X.tar.gz` for releases earlier than v5.9)
27+
`wget https://github.com/mattermost/mattermost-push-proxy/releases/download/vX.X.X/mattermost-push-proxy-linux-amd64.tar.gz`
28+
or
29+
`wget https://github.com/mattermost/mattermost-push-proxy/releases/download/vX.X.X/mattermost-push-proxy-freebsd-amd64.tar.gz`
2830

2931
In this command, `vX.X.X` refers to the release version you want to download. See {{< newtabref href="https://github.com/mattermost/mattermost-push-proxy/releases" title="Mattermost Push Notification Service releases" >}}.
3032

3133
2. If you're upgrading a previous version of the Mattermost Push Notification Service make sure to back up your `mattermost-push-proxy.json` file before continuing.
3234

33-
3. Unzip the downloaded Mattermost Push Notification Service using: `tar -xvzf mattermost-push-proxy.tar.gz`
35+
3. Unzip the downloaded Mattermost Push Notification Service using:
36+
`tar -xvzf mattermost-push-proxy-linux-amd64.tar.gz`
37+
or
38+
`tar -xvzf mattermost-push-proxy-freebsd-amd64.tar.gz`
3439

3540
4. Configure the Mattermost Push Notification service by editing the `mattermost-push-proxy.json` file at `/home/ubuntu/mattermost-push-proxy/config`. Follow the steps in the [Android](#set-up-mattermost-push-notification-service-to-send-android-push-notifications)
3641
and [iOS](#set-up-mattermost-push-notification-service-to-send-ios-push-notifications) sections to replace the values in the config file.
@@ -69,39 +74,32 @@ For the sake of making this guide simple we located the files at `/home/ubuntu/m
6974
7075
### Set up Mattermost push notification service to send iOS push notifications
7176
72-
- Double click the **Push Notifications Certificate** which is generated and downloaded while [Setting up Push Notifications for iOS]({{< ref "/contribute/more-info/mobile/push-notifications/ios" >}}) to add it to your Keychain Access. It downloads by default as `aps.cer`.
73-
74-
- Open **Keychain Access**, select the **login** keychain and **My Certificates** from the side menu.
75-
![image](/img/mobile/ios_keychain_select.png)
76-
77-
- Find the certificate you imported and then right click to **export** it as a **.p12** file
78-
![image](/img/mobile/ios_keychain_export.png)
79-
80-
- Enter a name for the filename and click **Save**
81-
![image](/img/mobile/ios_keychain_export_save.png)
82-
83-
- Leave the **password** blank and then click **OK**
84-
![image](/img/mobile/ios_keychain_export_password.png)
85-
86-
- Convert the downloaded certificate to **.pem**
87-
```sh
88-
$ openssl x509 -in aps.cer -inform DER -out aps_production.pem
89-
```
90-
- Extract the private key from the certificate you exported ..
91-
```sh
92-
$ openssl pkcs12 -in Certificates.p12 -out aps_production_priv.pem -nodes -clcerts -passin pass: -legacy -rc2
93-
```
94-
- Verify the certificate works with Apple
95-
```sh
96-
$ openssl s_client -connect gateway.push.apple.com:2195 -cert aps_production.pem -key aps_production_priv.pem
97-
```
98-
- Copy the private key file `aps_production_priv.pem` into your `mattermost-push-proxy/config` directory
99-
100-
- Open the **mattermost-push-proxy.json** file under the `mattermost-push-proxy/config` directory and add the path to the private key file as the value for **"ApplePushCertPrivate"** and the value for **"ApplePushTopic"** with your *Bundle Identifier*
101-
102-
![image](/img/mobile/proxy-config.png)
77+
Instead of certificates, we now recommend using an **APNs Auth Key (`.p8`)** to authenticate with Apple Push Notification service (APNs).
78+
If you haven’t generated your key yet, see [Generate an APNs Auth Key]({{< ref "/contribute/more-info/mobile/push-notifications/ios" >}}).
79+
80+
- Open the **mattermost-push-proxy.json** file under the `mattermost-push-proxy/config` directory and configure it with your key details:
81+
82+
```json
83+
"ApplePushSettings":[
84+
{
85+
"Type":"apple_rn",
86+
"ApplePushUseDevelopment":true,
87+
"ApplePushTopic":"your.bundle.id",
88+
"AppleAuthKeyFile":"./config/beta/YourAuthKeyFile.p8",
89+
"AppleAuthKeyID":"YourAuthKeyID",
90+
"AppleTeamID":"YourAppleTeamID"
91+
}
92+
],
93+
```
94+
- **ApplePushTopic**: Your app’s bundle ID (APNs topic).
95+
- **AppleAuthKeyFile**: Path to the `.p8` file.
96+
- **AppleAuthKeyID**: Key ID from Apple Developer portal.
97+
- **AppleTeamID**: Team ID from Apple Developer Membership.
98+
- **ApplePushUseDevelopment**: `true` for sandbox APNs, `false` for production.
10399
104-
In the {{< newtabref href="https://github.com/mattermost/mattermost-push-proxy/tree/master/cmd/renew_apple_cert" title="mattermost-push-proxy project" >}} there are some scripts to ease the process involved for updating the iOS notification certificates. Please check the README.md for further details.
100+
{{% note %}}
101+
If you are migrating from certificate-based authentication, you can remove the `ApplePushCertPrivate` field and replace it with the new `AppleAuthKeyFile`, `AppleAuthKeyID`, and `AppleTeamID` values.
102+
{{% /note %}}
105103
106104
### Configure the Mattermost Server to use the Mattermost push notification service
107105
@@ -162,39 +160,11 @@ Note that device IDs can change somewhat frequently, as they are tied to a devic
162160

163161
### Troubleshooting
164162

165-
##### High Sierra Apple Developer keys
166-
167-
Follow these instructions if you run into an error like below:
168-
```
169-
2018/04/13 12:39:24 CRIT Failed to load the apple pem cert err=failed to parse PKCS1 private key for type=apple_rn
170-
panic: Failed to load the apple pem cert err=failed to parse PKCS1 private key for type=apple_rn
171-
```
172-
173-
1. Follow the directions at {{< newtabref href="https://developer.apple.com/library/content/documentation/IDEs/Conceptual/AppDistributionGuide/DistributingEnterpriseProgramApps/DistributingEnterpriseProgramApps.html#//apple_ref/doc/uid/TP40012582-CH33-SW4" title="developer.apple.com" >}} to generate an Apple Push Notification service SSL Certificate, this should give you an `aps_production.cer`
174-
2. Convert the certificate format to .pem:
175-
- `openssl x509 -in aps.cer -inform DER -out aps_production.pem`
176-
3. Double click `aps_production.cer` to install it into the keychain tool
177-
4. Right click the private cert in keychain access and export to .p12
178-
5. Extract the private key from the certificate into an intermediate state:
179-
- `openssl pkcs12 -in Certificates.p12 -out intermediate.pem -nodes -clcerts`
180-
6. Generate an intermediate RSA private key
181-
- `openssl rsa -in intermediate.pem -out intermediate_rsa_priv.pem`
182-
7. Remove the private key information from intermediate.pem
183-
- `sed -i '/^-----BEGIN PRIVATE KEY-----$/,$d' intermediate.pem`
184-
8. Combine intermediate.pem and intermediate_rsa_priv.pem to create a valid bundle
185-
- `cat intermediate.pem intermediate_rsa_priv.pem >> aps_production_priv.pem && rm intermediate.pem intermediate_rsa_priv.pem`
186-
9. Verifying the certificate works with Apple:
187-
- `openssl s_client -connect gateway.push.apple.com:2195 -cert aps_production.pem -key aps_production_priv.pem`
188-
189163
##### DeviceTokenNotForTopic
190164

191165
**For iOS / Apple Push Notifications**: If the logs are reflecting DeviceTokenNotForTopic (error 400) this may be because you're using an older / previous Device ID. Re-run the queries you need to get device IDs and test.
192166
193-
This could also be because you generated a certificate for the wrong bundle ID. The bundle ID used in `mattermost-push-proxy.json` should be the same one as the app, and should be for the same app it was generated for.
194-
195-
##### *TLS: Unknown Certificate Authority* error
196-
197-
**For iOS / Apple Push Notifications**: If you see a message in the push proxy log that includes `tls: unknown certificate authority` for iOS devices, it's likely Apple has invalidated your client certificate, or you're using a client certificate without {{< newtabref href="https://developer.apple.com/news/?id=7gx0a2lp" title="the correct certificate authority." >}} To resolve this, follow [these instructions to generate a new certificate]({{< ref "/contribute/more-info/mobile/push-notifications/ios" >}}), and then [upload it to your push proxy server](#set-up-mattermost-push-notification-service-to-send-ios-push-notifications).
167+
This could also be because you generated a key for the wrong bundle ID. The bundle ID used in `mattermost-push-proxy.json` should be the same one as the app, and should be for the same app it was generated for.
198168
199169
### Reporting issues
200170

site/static/img/mobile/apns.png

-329 KB
Binary file not shown.
-129 KB
Binary file not shown.
214 KB
Loading
172 KB
Loading
72.8 KB
Loading
95.9 KB
Loading
99.1 KB
Loading
78.9 KB
Loading

0 commit comments

Comments
 (0)