From 4371added2bb27356f4d1350e8276dbb79fde29f Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Fri, 31 Mar 2023 17:48:42 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=8D=B5=E3=81=AE=E5=BD=A2=E5=BC=8F?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A32?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/dev/usbharu/hideout/plugins/ActivityPub.kt | 2 +- .../kotlin/dev/usbharu/hideout/service/UserAuthService.kt | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/dev/usbharu/hideout/plugins/ActivityPub.kt b/src/main/kotlin/dev/usbharu/hideout/plugins/ActivityPub.kt index a11146ae..79026295 100644 --- a/src/main/kotlin/dev/usbharu/hideout/plugins/ActivityPub.kt +++ b/src/main/kotlin/dev/usbharu/hideout/plugins/ActivityPub.kt @@ -164,7 +164,7 @@ class KtorKeyMap(private val userAuthRepository: IUserAuthService) : KeyMap { val publicBytes = Base64.getDecoder().decode( userAuthRepository.findByUsername( username - ).privateKey?.replace("-----BEGIN RSA PRIVATE KEY-----", "")?.replace("-----END RSA PRIVATE KEY-----", "") + ).privateKey?.replace("-----BEGIN PRIVATE KEY-----", "")?.replace("-----END PRIVATE KEY-----", "") ?.replace("\n", "") ) val x509EncodedKeySpec = PKCS8EncodedKeySpec(publicBytes) diff --git a/src/main/kotlin/dev/usbharu/hideout/service/UserAuthService.kt b/src/main/kotlin/dev/usbharu/hideout/service/UserAuthService.kt index 35812420..72ae5ae4 100644 --- a/src/main/kotlin/dev/usbharu/hideout/service/UserAuthService.kt +++ b/src/main/kotlin/dev/usbharu/hideout/service/UserAuthService.kt @@ -91,13 +91,13 @@ class UserAuthService( } public fun PublicKey.toPem(): String { - return "-----BEGIN RSA PUBLIC KEY-----" + + return "-----BEGIN PUBLIC KEY-----" + Base64.getEncoder().encodeToString(encoded).chunked(64).joinToString("\n") + - "-----END RSA PUBLIC KEY-----" + "-----END PUBLIC KEY-----" } public fun PrivateKey.toPem(): String { - return "-----BEGIN RSA PRIVATE KEY-----" + + return "-----BEGIN PRIVATE KEY-----" + Base64.getEncoder().encodeToString(encoded).chunked(64).joinToString("\n") + - "-----END RSA PRIVATE KEY-----" + "-----END PRIVATE KEY-----" }