Skip to content

Instantly share code, notes, and snippets.

@Carlos-Augusto
Created February 21, 2022 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Carlos-Augusto/b626a6c017ba4289aa0e71becd433c04 to your computer and use it in GitHub Desktop.
Save Carlos-Augusto/b626a6c017ba4289aa0e71becd433c04 to your computer and use it in GitHub Desktop.
How to create a CSR for the identity service
//https://blog.pinterjann.is/ed25519-certificates.html
//openssl genpkey -algorithm ED25519 > a273f05a-c6bc-4649-a1ef-88c9430d0420.key
//openssl req -new -outform der -out a273f05a-c6bc-4649-a1ef-88c9430d0420.der -key a273f05a-c6bc-4649-a1ef-88c9430d0420.key -config openssl-25519.cnf
val privKey = GeneratorKeyFactory.getPrivKey(Base64.getDecoder.decode("MC4CAQAwBQYDK2VwBCIEIHaun1X0BqHaZqy/DmB/EByXyUgX7a1f/x+kM+bPqPb8").slice(16, 48), Curve.Ed25519)
val hardwareDeviceId = "a273f05a-c6bc-4649-a1ef-88c9430d0420"
val created = DateUtil.nowUTC
val validNotAfter = Some(created.plusYears(6))
val validNotBefore = created
PublicKeyCreationHelpers.getPublicKey2(
privKey = privKey,
curveName = "ED25519",
created = created,
validNotAfter = validNotAfter,
validNotBefore = validNotBefore,
hardwareDeviceId = hardwareDeviceId
).toTry match {
case Failure(e) => throw e
case Success((_, keyAsString, _, _, _)) => println(keyAsString)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment