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-----" }