Class: SatMx::Signer

Inherits:
Object
  • Object
show all
Defined in:
lib/sat_mx/signer.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(document:, private_key:) ⇒ Signer

Returns a new instance of Signer.



10
11
12
13
# File 'lib/sat_mx/signer.rb', line 10

def initialize(document:, private_key:)
  @unsigned_document = Xmldsig::SignedDocument.new(document)
  @private_key = private_key
end

Class Method Details

.sign(document:, private_key:) ⇒ Object



6
7
8
# File 'lib/sat_mx/signer.rb', line 6

def self.sign(document:, private_key:)
  new(document:, private_key:).sign
end

Instance Method Details

#signObject



15
16
17
18
19
# File 'lib/sat_mx/signer.rb', line 15

def sign
  unsigned_document.sign do |data|
    private_key.sign(OpenSSL::Digest.new("SHA1"), data)
  end
end