web-push-libs/vapid

How to convert vapid key into a string?

TvoroG opened this issue · 2 comments

Can you help me? I don't know how to do it :) You have from_string method to convert to vapid key, but I need opposite of that.

I think i just need convert cryptography.hazmat.backends.openssl.ec._EllipticCurvePrivateKey to bytes and then base64 encode it.

Found how to get public key in string format from py_vapid/main.py:

raw_pub = vapid.public_key.public_bytes(
    serialization.Encoding.X962,
    serialization.PublicFormat.UncompressedPoint
)
b64urlencode(raw_pub)