PHP Coinbase Securing Callbacks

1

This is example callback verification code in Ruby (https://developers.coinbase.com/docs/wallet/notifications):

CALLBACK_DIGEST = OpenSSL::Digest.new("SHA256")

def self.verify_callback(body, signature)
  return false unless callback_signing_public_key
  callback_signing_public_key.verify(CALLBACK_DIGEST, signature.unpack("m0")[0], body)
  rescue OpenSSL::PKey::RSAError, ArgumentError
  false
end

def self.callback_signing_public_key
  @@callback_signing_public_key ||= nil
  return @@callback_signing_public_key if @@callback_signing_public_key
  path = File.expand_path(File.join(File.dirname(__FILE__), 'coinbase-callback.pub'))
  @@callback_signing_public_key = OpenSSL::PKey::RSA.new(File.read(path))
end

How can I do this in PHP ?

Eka

Posted 2016-09-08T08:47:46.053

Reputation: 11

Asking for someone to port code for you isn't a very good question. Perhaps you should be more specific in your question about the parts of the code you don't understand.Jestin 2016-09-21T15:32:49.477

No answers