lib/pingpp/webhook.rb in pingpp-2.0.15 vs lib/pingpp/webhook.rb in pingpp-2.1.0

- old
+ new

@@ -1,9 +1,9 @@ module Pingpp module Webhook - def self.verify?(request) - if !Pingpp.pub_key + def self.verify?(request, pub_key=Pingpp.pub_key) + if !pub_key return false end raw_data = nil if request.respond_to?('raw_post') @@ -25,10 +25,10 @@ formated_headers = Util.format_headers(headers) return false if !formated_headers.has_key?(:x_pingplusplus_signature) signature = formated_headers[:x_pingplusplus_signature] - rsa_public_key = OpenSSL::PKey.read(Pingpp.pub_key) + rsa_public_key = OpenSSL::PKey.read(pub_key) return rsa_public_key.verify(OpenSSL::Digest::SHA256.new, Base64.decode64(signature), raw_data) end end end