Sha256: bfac11205e20e3a406d148588828276bfd237cf968983dd40f09f1688419017b

Contents?: true

Size: 1.24 KB

Versions: 48

Compression:

Stored size: 1.24 KB

Contents

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

      ids = installed_identies
      finger_print = sha1_fingerprint(path)

      return ids.include? finger_print
    end

    # Legacy Method, use `installed?` instead
    # rubocop:disable Style/PredicateName
    def self.is_installed?(path)
      installed?(path)
    end
    # rubocop:enable Style/PredicateName

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

      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.delete!(':')
        return result
      rescue
        Helper.log.info result
        raise "Error parsing certificate '#{path}'"
      end
    end
  end
end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
fastlane_core-0.36.4 lib/fastlane_core/cert_checker.rb
fastlane_core-0.36.3 lib/fastlane_core/cert_checker.rb
fastlane_core-0.36.2 lib/fastlane_core/cert_checker.rb
fastlane_core-0.36.1 lib/fastlane_core/cert_checker.rb
fastlane_core-0.36.0 lib/fastlane_core/cert_checker.rb
fastlane_core-0.35.1 lib/fastlane_core/cert_checker.rb
fastlane_core-0.35.0 lib/fastlane_core/cert_checker.rb
fastlane_core-0.34.0 lib/fastlane_core/cert_checker.rb
fastlane_core-0.33.0 lib/fastlane_core/cert_checker.rb
fastlane_core-0.32.1 lib/fastlane_core/cert_checker.rb
fastlane_core-0.32.0 lib/fastlane_core/cert_checker.rb
fastlane_core-0.31.0 lib/fastlane_core/cert_checker.rb
fastlane_core-0.30.0 lib/fastlane_core/cert_checker.rb
fastlane_core-0.29.1 lib/fastlane_core/cert_checker.rb
fastlane_core-0.29.0 lib/fastlane_core/cert_checker.rb
fastlane_core-0.28.0 lib/fastlane_core/cert_checker.rb
fastlane_core-0.27.0 lib/fastlane_core/cert_checker.rb
fastlane_core-0.26.6 lib/fastlane_core/cert_checker.rb
fastlane_core-0.26.5 lib/fastlane_core/cert_checker.rb
fastlane_core-0.26.4 lib/fastlane_core/cert_checker.rb