From bf62807fa4d6b6b13891689fa036d6e5a4fc7eaf Mon Sep 17 00:00:00 2001 From: Anil Rhemtulla Date: Tue, 19 Mar 2024 14:55:49 -0400 Subject: [PATCH] Changes to allow OpenSSL3 to work --- lib/webpush/encryption.rb | 5 ++--- lib/webpush/vapid_key.rb | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) 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