Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PEM support to import / export keys #65

Merged
merged 3 commits into from
Mar 6, 2019
Merged

Conversation

collimarco
Copy link
Contributor

I have added two helper methods for importing / exporting keys in PEM format. It is useful for interoperability between different libraries and services that store or use the keys in different formats. For example it is useful in order to use this library if you already have existing keys in PEM format. It is also useful if you want to store your keys in PEM format, which is a de facto standard for keys.

# example import (from PEM to base64)
vapid_key = Webpush::VapidKey.from_pem "YOUR PEM GOES HERE"
vapid_key.public_key
vapid_key.private_key

# example export (to PEM)
vapid_key = Webpush.generate_key
vapid_key.to_pem

@zaru
Copy link
Owner

zaru commented Mar 6, 2019

@collimarco Thanks for awesome PR!
Please write example to README.

@collimarco
Copy link
Contributor Author

Thanks @zaru for the positive feedback! I have added an improvement to support PEM directly and added the examples to the readme.

@zaru zaru merged commit a1a97f4 into zaru:master Mar 6, 2019
@zaru
Copy link
Owner

zaru commented Mar 6, 2019

released!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants