fix: 鍵を強固に、PEMを修正

This commit is contained in:
usbharu 2023-04-29 16:47:58 +09:00
parent 93a554e988
commit 887db080d0
Signed by: usbharu
GPG Key ID: 6556747BF94EEBC8
1 changed files with 3 additions and 3 deletions

View File

@ -31,7 +31,7 @@ class UserAuthService(
override suspend fun generateKeyPair(): KeyPair {
val keyPairGenerator = KeyPairGenerator.getInstance("RSA")
keyPairGenerator.initialize(1024)
keyPairGenerator.initialize(2048)
return keyPairGenerator.generateKeyPair()
}
@ -44,11 +44,11 @@ class UserAuthService(
fun PublicKey.toPem(): String {
return "-----BEGIN PUBLIC KEY-----\n" +
Base64.getEncoder().encodeToString(encoded).chunked(64).joinToString("\n") +
"\n-----END PUBLIC KEY-----"
"\n-----END PUBLIC KEY-----\n"
}
fun PrivateKey.toPem(): String {
return "-----BEGIN PRIVATE KEY-----\n" +
Base64.getEncoder().encodeToString(encoded).chunked(64).joinToString("\n") +
"\n-----END PRIVATE KEY-----"
"\n-----END PRIVATE KEY-----\n"
}