Skip to content

Commit 93eacca

Browse files
crypto-key header to url-safe header for chrome browser
1 parent 939eeb4 commit 93eacca

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/main/java/nl/martijndwars/webpush/AbstractPushService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ protected final HttpRequest prepareRequest(Notification notification, Encoding e
166166
} else if (encoding == Encoding.AESGCM) {
167167
headers.put("Content-Encoding", "aesgcm");
168168
headers.put("Encryption", "salt=" + Base64.getUrlEncoder().withoutPadding().encodeToString(salt));
169-
headers.put("Crypto-Key", "dh=" + Base64.getUrlEncoder().encodeToString(dh));
169+
headers.put("Crypto-Key", "dh=" + Base64.getUrlEncoder().withoutPadding().encodeToString(dh));
170170
}
171171

172172
body = encrypted.getCiphertext();
@@ -208,9 +208,9 @@ protected final HttpRequest prepareRequest(Notification notification, Encoding e
208208
}
209209

210210
if (headers.containsKey("Crypto-Key")) {
211-
headers.put("Crypto-Key", headers.get("Crypto-Key") + ";p256ecdsa=" + Base64.getUrlEncoder().encodeToString(pk));
211+
headers.put("Crypto-Key", headers.get("Crypto-Key") + ";p256ecdsa=" + Base64.getUrlEncoder().withoutPadding().encodeToString(pk));
212212
} else {
213-
headers.put("Crypto-Key", "p256ecdsa=" + Base64.getUrlEncoder().encodeToString(pk));
213+
headers.put("Crypto-Key", "p256ecdsa=" + Base64.getUrlEncoder().withoutPadding().encodeToString(pk));
214214
}
215215
} else if (notification.isFcm() && getGcmApiKey() != null) {
216216
headers.put("Authorization", "key=" + getGcmApiKey());

src/main/java/nl/martijndwars/webpush/cli/handlers/GenerateKeyHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ public void run() throws InvalidAlgorithmParameterException, NoSuchAlgorithmExce
4242
}
4343

4444
System.out.println("PublicKey:");
45-
System.out.println(Base64.getUrlEncoder().encodeToString(encodedPublicKey));
45+
System.out.println(Base64.getUrlEncoder().withoutPadding().encodeToString(encodedPublicKey));
4646

4747
System.out.println("PrivateKey:");
48-
System.out.println(Base64.getUrlEncoder().encodeToString(encodedPrivateKey));
48+
System.out.println(Base64.getUrlEncoder().withoutPadding().encodeToString(encodedPrivateKey));
4949
}
5050

5151
/**

0 commit comments

Comments
 (0)