Created
April 11, 2020 15:19
-
-
Save tonytonyjan/40c236698e474db502ac857380e7534c to your computer and use it in GitHub Desktop.
Generate VAPID key pair by pure Ruby based on RFC8292
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://tools.ietf.org/html/rfc8292 | |
require 'openssl' | |
require 'base64' | |
ec = OpenSSL::PKey::EC.generate('prime256v1') | |
puts( | |
Base64.urlsafe_encode64(ec.public_key.to_bn.to_s(2), padding: false), | |
Base64.urlsafe_encode64(ec.private_key.to_s(2), padding: false) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment