web-push-libs / vapid

Apps and Libraries to support WebPush VAPID
Mozilla Public License 2.0
90 stars 27 forks source link

How to convert vapid key into a string? #79

Closed TvoroG closed 3 years ago

TvoroG commented 5 years ago

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.

TvoroG commented 5 years ago

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

TvoroG commented 5 years ago

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)