class SparkleAppcast::Signer

Attributes

private_key_path[R]

Public Class Methods

new(private_key_path) click to toggle source
# File lib/sparkle_appcast/signer.rb, line 8
def initialize(private_key_path)
  @private_key_path = private_key_path
end

Public Instance Methods

sign(data) click to toggle source
# 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

Private Instance Methods

private_key() click to toggle source
# File lib/sparkle_appcast/signer.rb, line 22
def private_key
  @private_key ||= OpenSSL::PKey::DSA.new(File.binread(private_key_path))
end