Module: ProvisionUtil
- Defined in:
- lib/provision_util.rb,
lib/provision_util/version.rb
Constant Summary collapse
- PROVISIONS =
"#{Dir.home}/Library/MobileDevice/Provisioning\ Profiles/".freeze
- VERSION =
"0.1.0"
Class Method Summary collapse
-
.check_public_key(public_key, p12_path, p12_phrase) ⇒ Boolean
Returns true if given public key is stored in p12.
-
.get_cert_from_provision(uuid_or_path) ⇒ OpenSSL::X509::Certificate
returns first certificate declared in provision DeveloperCertificates field.
-
.get_certs_from_provision(uuid_or_path) ⇒ Array
returns all certificates declared in provision DeveloperCertificates field.
-
.get_provision_content_plist(uuid_or_path) ⇒ Hash
returns provision profile data, parsed by Plist.
-
.get_provision_path(uuid_or_path) ⇒ Object
Returns path if argument is path or use it as uuid of provision in Provisioning\ Profiles dir.
Class Method Details
.check_public_key(public_key, p12_path, p12_phrase) ⇒ Boolean
Returns true if given public key is stored in p12
62 63 64 65 |
# File 'lib/provision_util.rb', line 62 def self.check_public_key(public_key, p12_path, p12_phrase) cert = OpenSSL::PKCS12.new(File.read(p12_path), p12_phrase) return cert.certificate.to_der == public_key.to_der end |
.get_cert_from_provision(uuid_or_path) ⇒ OpenSSL::X509::Certificate
returns first certificate declared in provision DeveloperCertificates field
39 40 41 42 43 44 |
# File 'lib/provision_util.rb', line 39 def self.get_cert_from_provision(uuid_or_path) provision_plist = get_provision_content_plist(uuid_or_path) cert_data = provision_plist['DeveloperCertificates'][0].string cert = OpenSSL::X509::Certificate.new(cert_data) return cert end |
.get_certs_from_provision(uuid_or_path) ⇒ Array
returns all certificates declared in provision DeveloperCertificates field
48 49 50 51 52 53 54 |
# File 'lib/provision_util.rb', line 48 def self.get_certs_from_provision(uuid_or_path) provision_plist = get_provision_content_plist(uuid_or_path) certs_data = provision_plist['DeveloperCertificates'].map do |cert_data| OpenSSL::X509::Certificate.new(cert_data.string) end return certs_data end |
.get_provision_content_plist(uuid_or_path) ⇒ Hash
returns provision profile data, parsed by Plist
28 29 30 31 32 33 34 |
# File 'lib/provision_util.rb', line 28 def self.get_provision_content_plist(uuid_or_path) File.open(get_provision_path(uuid_or_path)) do |data| p7 = OpenSSL::PKCS7.new(data) p7.verify([], CERT_STORE, nil, OpenSSL::PKCS7::NOVERIFY) return Plist.parse_xml(p7.data) end end |
.get_provision_path(uuid_or_path) ⇒ Object
Returns path if argument is path or use it as uuid of provision in Provisioning\ Profiles dir
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/provision_util.rb', line 13 def self.get_provision_path(uuid_or_path) if File.file?(uuid_or_path) return uuid_or_path else path = File.join PROVISIONS, "#{uuid_or_path}.mobileprovision" if not File.file?(path) raise "Cant find provision #{uuid_or_path} in path #{PROVISIONS}" else return path end end end |