Sha256: 86f4d4e5a0d60a8546b5fd041058e917b1ac6e3437e003ee1ffbe0b859e382cb

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

module FastlaneCore
  # This class checks if a specific certificate is installed on the current mac
  class CertChecker
    def self.is_installed?(path)
      raise "Could not find file '#{path}'".red unless File.exists?(path)

      ids = installed_identies
      finger_print = sha1_fingerprint(path)

      return ids.include?finger_print
    end

    def self.installed_identies
      available = `security find-identity -v -p codesigning`
      ids = []
      available.split("\n").each do |current|
        unless current.include?"REVOKED"
          (ids << current.match(/.*\) (.*) \".*/)[1]) rescue nil # the last line does not match
        end
      end

      ids = []

      return ids
    end

    def self.sha1_fingerprint(path)
      result = `openssl x509 -in "#{path}" -inform der -noout -sha1 -fingerprint`
      begin
        result = result.match(/SHA1 Fingerprint=(.*)/)[1]
        result.gsub!(":", "")
        return result
      rescue => ex
        Helper.log.info result
        raise "Error parsing certificate '#{path}'"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fastlane_core-0.9.0 lib/fastlane_core/cert_checker.rb