Class: SparkleAppcast::Signer

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(private_key_path) ⇒ Signer

Returns a new instance of Signer.



8
9
10
# File 'lib/sparkle_appcast/signer.rb', line 8

def initialize(private_key_path)
  @private_key_path = private_key_path
end

Instance Attribute Details

#private_key_pathObject (readonly)

Returns the value of attribute private_key_path.



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

def private_key_path
  @private_key_path
end

Instance Method Details

#sign(data) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/sparkle_appcast/signer.rb', line 12

def sign(data)
  # Sparkle is signing SHA1 digest with DSA private key and encoding it in Base64.
  # See <https://github.com/sparkle-project/Sparkle/blob/master/bin/sign_update>.
  digest = OpenSSL::Digest::SHA1.digest(data)
  signature = private_key.sign(OpenSSL::Digest::SHA1.new, digest)
  Base64.strict_encode64(signature)
end