Class: ItunesReceiptDecoder::Decode::TransactionReceipt
- Defined in:
- lib/itunes_receipt_decoder/decode/transaction_receipt.rb
Overview
ItunesReceiptDecoder::Decode::TransactionReceipt
Constant Summary collapse
- PUBLIC_KEY =
OpenSSL::PKey::RSA.new <<-PUBLIC_KEY -----BEGIN PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApLyvMpRDPgu8N4fNY4ny zNm+IE1atP6HZ9Ka3hpUnaLz34fkTMuTEXigMI80QcHTvmZtR2yYuOx61cndpeTq xnD0NdCR97PYChGZqzpiOr179FZP258kk1FQfCDVZk1m8xikE5YiFv0xp/Q5Zpv7 YmlcS5+UqEvo7FtkWhh5ihZ1Y0KkSdmMM96te9Y5BPTinQppjOtLEihLNEgHmw5Z +R9isAOfNrhOo9N1WdTzOgXKxTM7+MAGCQiT2+dNvxHzUiylFjUV80ECzQLR/PX4 xYS9Y2qG1raZ9oauX/0D1CiKWl2vvGV00fcaw5II9BytaegCTA6VFQe8vmpvwbOt oQIDAQAB -----END PUBLIC KEY----- PUBLIC_KEY
Instance Attribute Summary
Attributes inherited from Base
#environment, #options, #raw_receipt, #receipt
Instance Method Summary collapse
Methods inherited from Base
#initialize, #production?, #sandbox?
Constructor Details
This class inherits a constructor from ItunesReceiptDecoder::Decode::Base
Instance Method Details
#signature_valid? ⇒ Boolean
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/itunes_receipt_decoder/decode/transaction_receipt.rb', line 30 def signature_valid? version, sig, cert_length, cert = payload.fetch('signature').unpack('m').first.unpack('c a128 N a*') return false unless version == 2 && sig.size == 128 && cert.size == cert_length && (cert = OpenSSL::X509::Certificate.new(cert)) && cert.verify(PUBLIC_KEY) data = [version, purchase_info].pack('ca*') cert.public_key.verify(OpenSSL::Digest::SHA1.new, sig, data) end |
#style ⇒ Object
26 27 28 |
# File 'lib/itunes_receipt_decoder/decode/transaction_receipt.rb', line 26 def style :transaction end |