Sha256: 579d1b248398eb87c61774a00ae7d6fcfc76e65b6a9f950c9c2097d31684af28
Contents?: true
Size: 915 Bytes
Versions: 1
Compression:
Stored size: 915 Bytes
Contents
module BuhoCfdi require 'openssl' class Key attr_reader :private_key def initialize(file, password=nil) if file.is_a? String @private_key = file end end def seal(xml) xml = Nokogiri::XML(xml) signature = generate_seal(xml) xml.at_css('cfdi|Comprobante').set_attribute('Sello',signature) xml.to_xml end def generate_seal(xml) chain = original_chain(xml) key = OpenSSL::PKey::RSA.new(@private_key) digester = OpenSSL::Digest::SHA256.new signature = key.sign(digester, chain) signature = Base64.strict_encode64(signature) signature end def original_chain(invoice) invoice = invoice xslt = Nokogiri::XSLT(File.read('storage/xslt/cadenaoriginal_3_3.xslt')) chain = xslt.transform(invoice) chain.text.gsub("\n","") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
buho_cfdi-0.1.12 | lib/buho_cfdi/key.rb |