provision_util 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f5862693d8644a195a0660716015ebe9c6215b6c
4
+ data.tar.gz: 9367abd7b974e35437e322d57111a2c9bb7b13d3
5
+ SHA512:
6
+ metadata.gz: 10c0c494ffc67d5391f24ff16430c34f7052356fe338779b8c89137014c6888c71df6566a69cd1a54619a1af83c9655da433fc9d72bf11810467365c76a06823
7
+ data.tar.gz: 2635aaee71c0ede1df6714e8764259e63f15b521212c5f802a6945a0cc3972a4530f71d46abb9e8c7907513b19577bdde9bf4cbdd22cca31c92e6d2a5b3cace5
@@ -0,0 +1,11 @@
1
+ -----BEGIN PGP SIGNATURE-----
2
+ Version: GnuPG v1
3
+
4
+ iQEcBAABAgAGBQJXeQ+2AAoJEAPmZ1UHrajB19oIAJV0sisIPncIQ0nKZSam1hkD
5
+ Ue6JE/Hd6GbskQuv2K78afMMRk5C+cjW/DnbEUAuxC3Vi2LV4+e1ClgX7CZkKnP1
6
+ msRw8TOtFOY5W9E4AlMi24zLOUvy8ryx3+sYCyAeqqO8xzjO6U98/35K7FfjTTkZ
7
+ N8gG0NN2XlTxMjl/x874y/ZF+on+7wHMADQYfsWlhrCuLlql62pB08bv3QIESklG
8
+ gEl6A2DcgPTb9cfaF1hQ8BstVGlZLhvGUppQUOpyrRVU4dg9ODtcW/4dy4M6prIF
9
+ E6f8dwuMssOuxVyFhLMgJTfToOG5iHo1hXaqCjU3ZUH9vgldYSVw+G0kwaArgqM=
10
+ =KOJG
11
+ -----END PGP SIGNATURE-----
@@ -0,0 +1,11 @@
1
+ -----BEGIN PGP SIGNATURE-----
2
+ Version: GnuPG v1
3
+
4
+ iQEcBAABAgAGBQJXeQ+1AAoJEAPmZ1UHrajBVOIH/3OSdB3uhL8Gy9cpIe/5p5Xd
5
+ 3/Ax3nKkE6s1xgP3T88su0RHNgGvcYQtGyZblrgbReveI4jiO/A7I1Rgx2C1DQYt
6
+ T8wF3hEApE2AgrKxJRTlqtAk6gXFFOKO5g5i86IoksOBjhux1IH6dImqqXCoMEV2
7
+ 0Fsq/qCrCLz/gYVM+/pGbAuFmcOR+YqBcj8LrAUN5wFcxR0o31+TRD/J3WGrFHAh
8
+ ZokxqBOpiof0KcVzgZYwphYqnf5/Qfob8Pjg836lguCZwTDJI5OurLaE3NfZ+CSm
9
+ OzMl5L5IRaqIV2UpRR9ze+15Kns3k+hBKpSKACVkHmDo6zH96tng/W00n8pnrII=
10
+ =+fQ1
11
+ -----END PGP SIGNATURE-----
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Stanislav Shakirov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,44 @@
1
+ # ProvisionUtil
2
+ [![fastlane Plugin Badge]
3
+ (https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)]
4
+ (https://rubygems.org/gems/provision_util)
5
+
6
+ Little library to make validation of provision profile easier
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'provision_util'
14
+ ```
15
+
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install provision_util
20
+
21
+ ## Usage
22
+
23
+ requare 'provision_util'
24
+
25
+ uuid = 'your provision profile uuid'
26
+
27
+ # Hash of provision plist
28
+ content = ProvisionUtil::get_provision_content_plist(uuid)
29
+ puts content['AppIDName']
30
+
31
+ # OpenSSL::X509::Certificate which was used to sign provision
32
+ cert = get_cert_from_provision(uuid)
33
+ puts cert.subject
34
+
35
+ path_p12 = "cert.p12"
36
+ password_p12 = "secure123"
37
+
38
+ # compare provision public key with public key from local p12 file
39
+ is_valid = check_public_key(uuid, path_p12, password_p12)
40
+
41
+ ## License
42
+
43
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
44
+
@@ -0,0 +1,66 @@
1
+ require 'provision_util/version'
2
+ require 'openssl'
3
+ require 'open3'
4
+ require 'plist'
5
+
6
+ module ProvisionUtil
7
+ PROVISIONS = "#{Dir.home}/Library/MobileDevice/Provisioning\ Profiles/".freeze
8
+ CERT_STORE = OpenSSL::X509::Store.new.freeze
9
+ private_constant :CERT_STORE
10
+
11
+ # Returns path if argument is path or use it
12
+ # as uuid of provision in Provisioning\ Profiles dir
13
+ def self.get_provision_path(uuid_or_path)
14
+ if File.file?(uuid_or_path)
15
+ return uuid_or_path
16
+ else
17
+ path = File.join PROVISIONS, "#{uuid_or_path}.mobileprovision"
18
+ if not File.file?(path)
19
+ raise "Cant find provision #{uuid_or_path} in path #{PROVISIONS}"
20
+ else
21
+ return path
22
+ end
23
+ end
24
+ end
25
+
26
+ # returns provision profile data, parsed by Plist
27
+ # @return [Hash]
28
+ def self.get_provision_content_plist(uuid_or_path)
29
+ File.open(get_provision_path(uuid_or_path)) do |data|
30
+ p7 = OpenSSL::PKCS7.new(data)
31
+ p7.verify([], CERT_STORE, nil, OpenSSL::PKCS7::NOVERIFY)
32
+ return Plist.parse_xml(p7.data)
33
+ end
34
+ end
35
+
36
+
37
+ # returns first certificate declared in provision DeveloperCertificates field
38
+ # @return [OpenSSL::X509::Certificate]
39
+ def self.get_cert_from_provision(uuid_or_path)
40
+ provision_plist = get_provision_content_plist(uuid_or_path)
41
+ cert_data = provision_plist['DeveloperCertificates'][0].string
42
+ cert = OpenSSL::X509::Certificate.new(cert_data)
43
+ return cert
44
+ end
45
+
46
+ # returns all certificates declared in provision DeveloperCertificates field
47
+ # @return [Array] of OpenSSL::X509::Certificate
48
+ def self.get_certs_from_provision(uuid_or_path)
49
+ provision_plist = get_provision_content_plist(uuid_or_path)
50
+ certs_data = provision_plist['DeveloperCertificates'].map do |cert_data|
51
+ OpenSSL::X509::Certificate.new(cert_data.string)
52
+ end
53
+ return certs_data
54
+ end
55
+
56
+
57
+ # Returns true if given public key is stored in p12
58
+ # @return [Boolean]
59
+ # @param [OpenSSL::X509::Certificate] public_key public key to check
60
+ # @param [String] p12_path path to p12 file
61
+ # @param [String] p12_phrase password to p12 file
62
+ def self.check_public_key(public_key, p12_path, p12_phrase)
63
+ cert = OpenSSL::PKCS12.new(File.read(p12_path), p12_phrase)
64
+ return cert.certificate.to_der == public_key.to_der
65
+ end
66
+ end
@@ -0,0 +1,3 @@
1
+ module ProvisionUtil
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: provision_util
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - punksta
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-07-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nokogiri
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: plist
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.12'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.12'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ description: "You can read provision profile into Hash, get signed certificate\nand
70
+ verify it with p12 files "
71
+ email:
72
+ - skinnystas@gmail.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - LICENSE
78
+ - README.md
79
+ - lib/provision_util.rb
80
+ - lib/provision_util/version.rb
81
+ homepage: https://github.com/punksta/provision_util
82
+ licenses:
83
+ - MIT
84
+ metadata: {}
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ requirements: []
100
+ rubyforge_project:
101
+ rubygems_version: 2.5.1
102
+ signing_key:
103
+ specification_version: 4
104
+ summary: Little library to working with provision profiles and certificates
105
+ test_files: []
@@ -0,0 +1,11 @@
1
+ -----BEGIN PGP SIGNATURE-----
2
+ Version: GnuPG v1
3
+
4
+ iQEcBAABAgAGBQJXeQ+dAAoJEAPmZ1UHrajBBpAH+QEe/D+IrQ+MbZ3O5QyIiy4b
5
+ EDv2CD6656Er53YeK0sl3IHPJJs436YLYHSGDp6Aqturvqt3G1NfU8mXcEwU4Pqd
6
+ KCFgB7mfO+DAFWnqPq3wT/SOkLZ7p8WiDbuXMjRtTpyvtRUp9ZcWR29Za0h40oek
7
+ IdZKQ3cbIv27q1JDlidHinv9kW0FL04hKxbcLSpkvIc/A8fXchPXkC4XFQL2LOdY
8
+ kwQBOFBLgU47SN6rEPfLD5Svwwb0sOA/WHdRMaomPHD7A+XkyutNk7MeH8aPZMk7
9
+ g/PmwZ3zX3tVKUyO/5Ph9HSOwT+KGtF7tELYh6VC/Hx9947F22n/IMhFX5fberM=
10
+ =1LWg
11
+ -----END PGP SIGNATURE-----