mirror of https://github.com/usbharu/Hideout.git
fix: 鍵の形式を修正2
This commit is contained in:
parent
bc4807ddc9
commit
aaedafff95
|
@ -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)
|
||||
|
|
|
@ -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-----"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue