Class: FastlaneCore::CertChecker
- Inherits:
-
Object
- Object
- FastlaneCore::CertChecker
- Defined in:
- lib/fastlane_core/cert_checker.rb
Overview
This class checks if a specific certificate is installed on the current mac
Class Method Summary collapse
- .install_wwdr_certificate ⇒ Object
- .installed?(path) ⇒ Boolean
-
.installed_identies ⇒ Object
rubocop:enable Style/PredicateName.
-
.is_installed?(path) ⇒ Boolean
Legacy Method, use ‘installed?` instead rubocop:disable Style/PredicateName.
- .sha1_fingerprint(path) ⇒ Object
- .wwdr_certificate_installed? ⇒ Boolean
Class Method Details
.install_wwdr_certificate ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/fastlane_core/cert_checker.rb', line 47 def self.install_wwdr_certificate Dir.chdir('/tmp') do url = 'https://developer.apple.com/certificationauthority/AppleWWDRCA.cer' filename = File.basename(url) `curl -O #{url} && security import #{filename} -k login.keychain` UI.user_error!("Could not install WWDR certificate") unless $?.success? end end |
.installed?(path) ⇒ Boolean
4 5 6 7 8 9 10 11 |
# File 'lib/fastlane_core/cert_checker.rb', line 4 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 |
.installed_identies ⇒ Object
rubocop:enable Style/PredicateName
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/fastlane_core/cert_checker.rb', line 20 def self.installed_identies install_wwdr_certificate unless wwdr_certificate_installed? available = `security find-identity -v -p codesigning` if available.include?("0 valid identities found") UI.error("Looks like there are no local code signing identities found, you can run `security find-identity -v -p codesigning` to get this output. Check out this reply for more: https://stackoverflow.com/questions/35390072/this-certificate-has-an-invalid-issuer-apple-push-services") end 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 |
.is_installed?(path) ⇒ Boolean
Legacy Method, use ‘installed?` instead rubocop:disable Style/PredicateName
15 16 17 |
# File 'lib/fastlane_core/cert_checker.rb', line 15 def self.is_installed?(path) installed?(path) end |
.sha1_fingerprint(path) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/fastlane_core/cert_checker.rb', line 56 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 |
.wwdr_certificate_installed? ⇒ Boolean
41 42 43 44 45 |
# File 'lib/fastlane_core/cert_checker.rb', line 41 def self.wwdr_certificate_installed? certificate_name = "Apple Worldwide Developer Relations Certification Authority" response = Helper.backticks("security find-certificate -c '#{certificate_name}'", print: $verbose) return response.include?("attributes:") end |