0

I'm creating JWT parser and now I need to create public key. I made it in Kotlin. But now I have to create same parser in Python. But I got stuck in creating X.509 certificate in python. I tried with cryptography library but with no success. Code in Kotlin. Thanks for responses.

val factory = KeyFactory.getInstance("EC")
val publicSpec = X509EncodedKeySpec(Base64.getMimeDecoder().decode(key))
return factory.generatePublic(publicSpec)
Patrik Dendis
  • 313
  • 6
  • 20

1 Answers1

1

You should probably combine this tutorial about generating a self-signed certificate and replacing the private key generation with this material.

Key generation example with SECP384R1:

from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import ec
key = ec.generate_private_key(
     ec.SECP384R1(), default_backend()
)
Lou_is
  • 259
  • 3
  • 11