Skip to content

Commit a450f68

Browse files
committed
bug: append vapid and encryption headers with a ';'
FCM, unfortunately, rejects multiple parameter sets for Crypto-Key. This is a work-around fix until the issue is properly resolved by the respective working groups. closes #8
1 parent bdf3d3e commit a450f68

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

pywebpush/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,10 @@ def send(self, data, headers={}, ttl=0, gcm_key=None, reg_id=None):
176176
headers = CaseInsensitiveDict(headers)
177177
crypto_key = headers.get("crypto-key", "")
178178
if crypto_key:
179-
crypto_key += ','
179+
# due to some confusion by a push service provider, we should
180+
# use ';' instead of ',' to append the headers.
181+
# see https://github.com/webpush-wg/webpush-encryption/issues/6
182+
crypto_key += ';'
180183
crypto_key += "keyid=p256dh;dh=" + encoded["crypto_key"].decode('utf8')
181184
headers.update({
182185
'crypto-key': crypto_key,

pywebpush/tests/test_webpush.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def test_send(self, mock_post):
106106
ok_('encryption' in pheaders)
107107
eq_(pheaders.get('AUTHENTICATION'), headers.get('Authentication'))
108108
ckey = pheaders.get('crypto-key')
109-
ok_('pre-existing,' in ckey)
109+
ok_('pre-existing' in ckey)
110110
eq_(pheaders.get('content-encoding'), 'aesgcm')
111111

112112
def test_ci_dict(self):

0 commit comments

Comments
 (0)