pem 0.3.8 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d017f22c946bf5b7edc3f19207fc18f4a7f44d74
4
- data.tar.gz: a768d2968115885940b6eae235e986918b4415e1
3
+ metadata.gz: 53a49d82dfa51942bda7945a2abe14519aa1628d
4
+ data.tar.gz: 18add6dbe91bfb711a6277001f2317e7b40b023b
5
5
  SHA512:
6
- metadata.gz: de12a00972b77b529f0636029c919f491607d38b7d65e3781297ae17880390da23e951c3a4b7e12ebfadca519a515474773037d4e56ea917f0696d4582a39ac8
7
- data.tar.gz: 8e08fb66e95a7641021a929934c8898a4b45133d485c9f6588b2b5030ad592869dbd68fa0a4fc27f3faa6c92c29f2d4e0682e57ef7f6b71e4a1492152391b871
6
+ metadata.gz: d79b9265d80ad370c50339a890e3aeafbac1ee3a7a7cdf94ab053a48739bb5d7863f423ed8b15d5d77759fd5e8bd4a9f8d89a4d2e258e5762060db51e0151f9f
7
+ data.tar.gz: 4699b6fa184d3e69bd472e41aa3ee29fc8fbdd82e24c60fcdc3655473004e037ae034a8dd68d926899a97e6f404f4e397f33073da7d1c0c9e83d39fe48cab5fa
data/bin/pem CHANGED
@@ -42,4 +42,9 @@ class PemApplication
42
42
  end
43
43
  end
44
44
 
45
- PemApplication.new.run
45
+ begin
46
+ FastlaneCore::UpdateChecker.start_looking_for_update('pem')
47
+ PemApplication.new.run
48
+ ensure
49
+ FastlaneCore::UpdateChecker.show_update_status('pem', PEM::VERSION)
50
+ end
data/lib/pem.rb CHANGED
@@ -20,6 +20,5 @@ module PEM
20
20
 
21
21
  Helper = FastlaneCore::Helper # you gotta love Ruby: Helper.* should use the Helper class contained in FastlaneCore
22
22
 
23
- FastlaneCore::UpdateChecker.verify_latest_version('pem', PEM::VERSION)
24
23
  DependencyChecker.check_dependencies
25
24
  end
@@ -1,5 +1,8 @@
1
1
  module PEM
2
2
  class CertManager
3
+
4
+ attr_accessor :rsa_file, :cert_file, :pem_file, :certificate_type, :passphrase
5
+
3
6
  # Download the cert, do all kinds of Keychain related things
4
7
  def run
5
8
  # Keychain (security) documentation: https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/security.1.html
@@ -9,36 +12,39 @@ module PEM
9
12
 
10
13
  dev = PEM::DeveloperCenter.new
11
14
 
12
- cert_file = dev.fetch_cer_file
13
- rsa_file = File.join(TMP_FOLDER, 'private_key.key')
14
-
15
- pem_temp = File.join(TMP_FOLDER, 'pem_temp.pem')
16
-
17
- certificate_type = (PEM.config[:development] ? 'development' : 'production')
15
+ self.cert_file = dev.fetch_cer_file
16
+ self.rsa_file = File.join(TMP_FOLDER, 'private_key.key')
17
+ self.certificate_type = (PEM.config[:development] ? 'development' : 'production')
18
+ self.pem_file = File.join(TMP_FOLDER, "#{certificate_type}_#{PEM.config[:app_identifier]}.pem")
19
+ self.passphrase = ''
18
20
 
19
-
20
- pem_file = File.join(TMP_FOLDER, "#{certificate_type}_#{PEM.config[:app_identifier]}.pem")
21
- command("openssl x509 -inform der -in '#{cert_file}' -out #{pem_temp}")
22
- content = File.read(pem_temp) + File.read(rsa_file)
23
- File.write(pem_file, content)
21
+ File.write(pem_file, pem_certificate)
24
22
 
25
23
  # Generate p12 file as well
26
24
  if PEM.config[:generate_p12]
27
- output = "#{certificate_type}.p12"
28
- command("openssl pkcs12 -export -password pass:"" -in '#{pem_file}' -inkey '#{pem_file}' -out '#{output}'")
25
+ output = "#{certificate_type}_#{PEM.config[:app_identifier]}.p12"
26
+ File.write(output, p12_certificate.to_der)
29
27
  puts output.green
30
28
  end
31
-
29
+
32
30
  return pem_file, rsa_file
33
31
  end
34
32
 
35
- private
36
- # Output the command, execute it, return its result
37
- def command(com)
38
- puts com.yellow
39
- result = `#{com}`
40
- puts result if (result || '').length > 0
41
- result
42
- end
33
+ def private_key
34
+ OpenSSL::PKey::RSA.new(File.read(rsa_file))
35
+ end
36
+
37
+ def x509_certificate
38
+ OpenSSL::X509::Certificate.new(File.read(cert_file))
39
+ end
40
+
41
+ def p12_certificate
42
+ OpenSSL::PKCS12.create(passphrase, certificate_type, private_key, x509_certificate)
43
+ end
44
+
45
+ def pem_certificate
46
+ x509_certificate.to_pem + private_key.to_pem
47
+ end
43
48
  end
44
- end
49
+ end
50
+
@@ -99,13 +99,9 @@ module PEM
99
99
  url = [host, url].join('')
100
100
  Helper.log.info "Downloading URL: '#{url}'"
101
101
 
102
- cookieString = ""
102
+ cookie_string = page.driver.cookies.collect { |key, cookie| "#{cookie.name}=#{cookie.value}" }.join(";")
103
103
 
104
- page.driver.cookies.each do |key, cookie|
105
- cookieString << "#{cookie.name}=#{cookie.value};" # append all known cookies
106
- end
107
-
108
- data = open(url, {'Cookie' => cookieString}).read
104
+ data = open(url, {'Cookie' => cookie_string}).read
109
105
 
110
106
  raise "Something went wrong when downloading the certificate" unless data
111
107
 
data/lib/pem/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module PEM
2
- VERSION = "0.3.8"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.8
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felix Krause
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-09 00:00:00.000000000 Z
11
+ date: 2015-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fastlane_core
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '>='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.3.1
19
+ version: 0.5.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '>='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.3.1
26
+ version: 0.5.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement