From 6ae7c42af78568dba6678ac01301e8a782da8967 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 1 Oct 2018 15:00:22 +0300 Subject: ActivityPub: fix public key serialization --- juick-server/src/main/java/com/juick/server/KeystoreManager.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'juick-server/src') diff --git a/juick-server/src/main/java/com/juick/server/KeystoreManager.java b/juick-server/src/main/java/com/juick/server/KeystoreManager.java index 8bf93a7b..75d72e72 100644 --- a/juick-server/src/main/java/com/juick/server/KeystoreManager.java +++ b/juick-server/src/main/java/com/juick/server/KeystoreManager.java @@ -14,6 +14,8 @@ import java.io.InputStream; import java.security.*; import java.security.cert.Certificate; import java.security.cert.CertificateException; +import java.util.Arrays; +import java.util.stream.Collectors; @Component public class KeystoreManager { @@ -60,7 +62,8 @@ public class KeystoreManager { return null; } public String getPublicKey() { - return String.format("-----BEGIN RSA PUBLIC KEY-----\n%s\n-----END RSA PUBLIC KEY-----\n", - new String(Base64Utils.encode(getKeyPair().getPublic().getEncoded()))); + String[] key = Base64Utils.encodeToString(getKeyPair().getPublic().getEncoded()).split("(?<=\\G.{64})"); + return String.format("-----BEGIN PUBLIC KEY-----\n%s\n-----END PUBLIC KEY-----\n", + Arrays.asList(key).stream().collect(Collectors.joining("\n"))); } } -- cgit v1.2.3