diff --git a/lib/webpush/encryption.rb b/lib/webpush/encryption.rb index 099e42e..ea661a7 100644 --- a/lib/webpush/encryption.rb +++ b/lib/webpush/encryption.rb @@ -11,9 +11,8 @@ def encrypt(message, p256dh, auth) group_name = 'prime256v1' salt = Random.new.bytes(16) - server = OpenSSL::PKey::EC.new(group_name) - server.generate_key - server_public_key_bn = server.public_key.to_bn + key = OpenSSL::PKey::EC.generate(group_name) + server_public_key_bn = key.public_key.to_bn group = OpenSSL::PKey::EC::Group.new(group_name) client_public_key_bn = OpenSSL::BN.new(Webpush.decode64(p256dh), 2) diff --git a/lib/webpush/vapid_key.rb b/lib/webpush/vapid_key.rb index d2b953c..4579674 100644 --- a/lib/webpush/vapid_key.rb +++ b/lib/webpush/vapid_key.rb @@ -31,8 +31,7 @@ def self.from_pem(pem) attr_reader :curve def initialize - @curve = OpenSSL::PKey::EC.new('prime256v1') - @curve.generate_key + @curve = OpenSSL::PKey::EC.generate('prime256v1') end # Retrieve the encoded elliptic curve public key for VAPID protocol