Skip to content

Commit cacacf5

Browse files
committed
generate VAPID key encoded in the URL-safe variant of Base64
1 parent 030b2a7 commit cacacf5

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ There are several good examples and tutorials on the web:
7171
* you may want to take a look at my own implementation: [sw.js](https://github.com/Minishlink/physbook/blob/2ed8b9a8a217446c9747e9191a50d6312651125d/web/service-worker.js) and [app.js](https://github.com/Minishlink/physbook/blob/d6855ca8f485556ab2ee5c047688fbf745367045/app/Resources/public/js/app.js)
7272

7373
### Authentication
74-
Browsers need to verify your identity. At the moment, some browsers don't force you but you'll have to do it in the future, so why not now?
75-
A standard called VAPID can authenticate you for all browsers. You'll need to create and provide a public and private key for your server.
74+
Browsers need to verify your identity. A standard called VAPID can authenticate you for all browsers. You'll need to create and provide a public and private key for your server.
7675

7776
You can specify your authentication details when instantiating WebPush:
7877
```php
@@ -86,8 +85,8 @@ $auth = array(
8685
'GCM' => 'MY_GCM_API_KEY', // deprecated and optional, it's here only for compatibility reasons
8786
'VAPID' => array(
8887
'subject' => 'mailto:[email protected]', // can be a mailto: or your website address
89-
'publicKey' => '88 chars', // uncompressed public key P-256
90-
'privateKey' => '44 chars', // in fact the secret multiplier of the private key
88+
'publicKey' => '~88 chars', // uncompressed public key P-256 encoded in Base64-URL
89+
'privateKey' => '~44 chars', // in fact the secret multiplier of the private key encoded in Base64-URL
9190
),
9291
);
9392

@@ -98,8 +97,8 @@ $webPush->sendNotification($endpoint, null, null, null, true);
9897
In order to generate the public and private keys, enter the following in your Linux bash:
9998
```
10099
$ openssl ecparam -genkey -name prime256v1 -out private_key.pem
101-
$ openssl ec -in private_key.pem -pubout -outform DER|tail -c 65|base64 >> public_key.txt
102-
$ openssl ec -in private_key.pem -outform DER|tail -c +8|head -c 32|base64 >> private_key.txt
100+
$ openssl ec -in private_key.pem -pubout -outform DER|tail -c 65|base64|tr -d '=' |tr '/+' '_-' >> public_key.txt
101+
$ openssl ec -in private_key.pem -outform DER|tail -c +8|head -c 32|base64|tr -d '=' |tr '/+' '_-' >> private_key.txt
103102
```
104103

105104
### Notification options

0 commit comments

Comments
 (0)