leotaku / web-push-native

Pure rust implementation of web-push and related standards
Apache License 2.0
6 stars 1 forks source link

Generating VAPID private / public key #2

Closed jsyrjala closed 1 year ago

jsyrjala commented 1 year ago

How could I generate a suitable VAPID private / public key?

Maybe this library should also have a function to generate the keys?

leotaku commented 1 year ago

As you can see in the documentation WebPushBuilder.with_vapid simply uses an ES256KeyPair, as defined by the jwt_simple crate, which is also re-exported at the root of the web-push-native crate. You should therefore be able to use ES256KeyPair::generate to generate a suitable key pair. Because this and various other methods to retrieve key pairs are already defined for us, web-push-native does not define its own methods of generating key pairs.

I hope this answers your question!

jsyrjala commented 1 year ago

Thanks a lot, just what I was looking for.

leotaku commented 1 year ago

Great! In that case, I will close the issue now. Feel free to reopen or create new issues if anything else is unclear.