exportation 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 59620a48ca2b2f33b91e71f3f89e17005ed8070b
4
+ data.tar.gz: 2bd448ebeeb9db0ce4eb62a8c6a287f3610f8c22
5
+ SHA512:
6
+ metadata.gz: bf283454025f616082913549e591ac2a512cd018393e6bb462f3ae89f2697d4c691f5eaace8e494eeef6bed71f1620fae3cf8263fb74ac75eeb8f5350c83a33d
7
+ data.tar.gz: f9f64013471f489cc0434ea56e3f278490b0ef475df28f37a13b834da9bd080603794d2967f0a12f463f4c82568767b95841e8f545e2403380da7bd3535b4055
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Josh Holtz
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # exportation
2
+ CLI tool of easy exporting, encrypting, and decrypting of certificates and private keys.
3
+
4
+ ### Features in progress
5
+ - Integrate with [fastlane](https://github.com/KrauseFx/fastlane) :rocket:
6
+ - Create a separate keychain with the certificates and private keys for use on CI systems :grinning:
7
+
8
+ ## Commands
9
+ Exportation has three different commands: `export`, `encrypt`, and `decrypt`.
10
+
11
+ ### Export from Keychain Access
12
+ **Be lazy!** `export` uses AppleScript to control the "Keychain Access" app to export a certificate and private to be used for CI (continuous integration) or for other developers.
13
+ ```sh
14
+ exportation export --name "Your Company LLC"
15
+ ```
16
+
17
+ ### Encrypting certificate and private key
18
+ **Be safe!** `encrypt` does exactly what it says - it encrypts. It uses AES-256 to encrypt your certificate, private keys and provisioning profiles (any file really) to store safely in your repository for CIs or other developers to access. All files will be appened with a `.enc` extension.
19
+ ```sh
20
+ exportation encrypt exported.cer exported.p12 --password dudethis
21
+ ```
22
+
23
+ ### Decrypting certificate and private key
24
+ **Be awesome!** `decrypt` decrypts your encrypted files to use on your CI or for other developers to install. *BE CAREFULL TO NOT COMMIT THESE BACK INTO YOUR REPO*
25
+ ```sh
26
+ exportation decrypt exported.cer.enc exported.p12.enc --password dudethis
27
+ ```
28
+
29
+ ## Using the internals
30
+
31
+ ### Compiling and running the AppleScript directly
32
+ *You shouldn't ever have to do this unless I messed stuff up :)*
33
+
34
+ ### Compile
35
+ ```sh
36
+ osacompile -o applescript/exportation.scpt applescript/exportation.applescript
37
+ ```
38
+
39
+ ### Run
40
+ Always put all for arguments in strings because I don't do AppleScript well :grimacing:
41
+ ```sh
42
+ osascript applescript/exportation.scpt "~/directory_you_want_to_export_to/" "dist" "iPhone Distribution: Your Company LLC" "thepassword"
43
+ ```
Binary file
data/bin/exportation ADDED
@@ -0,0 +1,84 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.push File.expand_path('../../lib', __FILE__)
4
+
5
+ require 'exportation'
6
+
7
+ require 'rubygems'
8
+ require 'commander'
9
+
10
+ class ExportationApplication
11
+ include Commander::Methods
12
+
13
+ def run
14
+ program :name, 'Exportation'
15
+ program :version, '0.1.0'
16
+ program :description, 'CLI tool of easy exporting, encrypting, and decrypting of certificates and private keys.'
17
+
18
+ command :export do |c|
19
+ c.syntax = 'exportation export [options]'
20
+ c.description = 'Exports certificate and private key from Keychain Access'
21
+ c.option '--path STRING', String, 'Path to save certificate and private key'
22
+ c.option '--filename STRING', String, 'File name to save certificate and private key as'
23
+ c.option '--name STRING', String, 'Common name of the cert as it is displayed in Keychain Access'
24
+ c.option '--password STRING', String, 'Password to use for the private key'
25
+ c.action do |args, options|
26
+ options.default path: "./", filename:"exported", password: ""
27
+
28
+ raise "--name is required" unless options.name
29
+
30
+ Exportation::Export.new(
31
+ path: options.path,
32
+ filename: options.filename,
33
+ name: options.name,
34
+ password: options.password
35
+ ).run
36
+
37
+ end
38
+ end
39
+
40
+ command :encrypt do |c|
41
+ c.syntax = 'exportation encrypt [options]'
42
+ c.description = 'Encrypts certificates, private keys, and provisioning profiles with AES'
43
+ c.option '--password STRING', String, 'Password to use for the encryption'
44
+ c.option '--output STRING', String, 'Output directory for files (defaults to where original files are located)'
45
+ c.option '--force', 'Forces all files to decrypted (will encrypt decrypted files)'
46
+ c.action do |args, options|
47
+ options.default output: nil
48
+
49
+ raise "--password is required" unless options.password
50
+
51
+ Exportation::Crypter.new(
52
+ files: args,
53
+ password: options.password,
54
+ output: options.output
55
+ ).run :en, options.force
56
+
57
+ end
58
+ end
59
+
60
+ command :decrypt do |c|
61
+ c.syntax = 'exportation decrypt [options]'
62
+ c.description = 'Decrypts certificates, private keys, and provisioning profiles with AES'
63
+ c.option '--password STRING', String, 'Password to use for the decryption'
64
+ c.option '--output STRING', String, 'Output directory for files (defaults to where original files are located)'
65
+ c.option '--force', 'Forces all files to decrypted (will encrypt decrypted files)'
66
+ c.action do |args, options|
67
+ options.default output: nil
68
+
69
+ raise "--password is required" unless options.password
70
+
71
+ Exportation::Crypter.new(
72
+ files: args,
73
+ password: options.password,
74
+ output: options.output
75
+ ).run :de, options.force
76
+
77
+ end
78
+ end
79
+
80
+ run!
81
+ end
82
+ end
83
+
84
+ ExportationApplication.new.run
@@ -0,0 +1,98 @@
1
+ module Exportation
2
+
3
+ def self.gem_path
4
+ if Gem::Specification::find_all_by_name('exportation').any?
5
+ puts "looking in gem specification - #{Gem::Specification.find_by_name('exportation').gem_dir}"
6
+ return Gem::Specification.find_by_name('exportation').gem_dir
7
+ else
8
+ puts "using current directory"
9
+ return './'
10
+ end
11
+ end
12
+
13
+ def self.applescript_path
14
+ File.join(gem_path, 'applescript', 'exportation.scpt')
15
+ end
16
+
17
+ class Export
18
+
19
+ attr_accessor :path, :filename, :name, :password
20
+
21
+ def initialize(options)
22
+ @path = options[:path]
23
+ @filename = options[:filename]
24
+ @name = options[:name]
25
+ @password = options[:password]
26
+ end
27
+
28
+ def run
29
+
30
+ abs_path = File.expand_path path
31
+ abs_path += '/' unless abs_path.end_with? '/'
32
+
33
+ bash = "osascript #{Exportation.applescript_path} " +
34
+ "\"#{abs_path}\" " +
35
+ "\"#{filename}\" " +
36
+ "\"#{name}\" " +
37
+ "\"#{password}\" "
38
+
39
+ puts "Running: #{bash}"
40
+ `#{bash}`
41
+
42
+ end
43
+
44
+ end
45
+
46
+ class Crypter
47
+
48
+ attr_accessor :files, :password, :output
49
+
50
+ def initialize(options)
51
+ @files = options[:files]
52
+ @password = options[:password]
53
+ @output = options[:output]
54
+ end
55
+
56
+ def run(crypt, force = false)
57
+
58
+ unless force
59
+ if crypt == :en
60
+ # Verify files are not already encrypted
61
+ files.each do |file|
62
+ raise 'Some of these files may be encrypted (ending with .enc)' if file.end_with? '.enc'
63
+ end
64
+ elsif crypt == :de
65
+ # Verify files are not already decrypted
66
+ files.each do |file|
67
+ raise 'Some of these files may be encrypted (ending with .enc)' unless file.end_with? '.enc'
68
+ end
69
+ end
70
+ end
71
+
72
+ # Does the stuff
73
+ files.each do |file|
74
+ if File.exists? file
75
+ output_file = file
76
+ if output
77
+ output_file = File.join(output, File.basename(file))
78
+ end
79
+
80
+ if crypt == :en
81
+ output_file += '.enc'
82
+ elsif crypt == :de
83
+ output_file = output_file.gsub('.enc','')
84
+ end
85
+
86
+ bash = "openssl aes-256-cbc -k \"#{password}\" -in #{file} -out #{output_file} -a"
87
+ puts "Running: #{bash}"
88
+ `#{bash}`
89
+ else
90
+ puts "File does not exist - #{file}"
91
+ end
92
+ end
93
+
94
+ end
95
+
96
+ end
97
+
98
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: exportation
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Josh Holtz
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: dotenv
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: commander
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '4.3'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '4.3'
41
+ description: CLI tool of easy exporting, encrypting, and decrypting of certificates
42
+ and private keys using Keychain Acess and openssl
43
+ email: me@joshholtz.com
44
+ executables:
45
+ - exportation
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - LICENSE
50
+ - README.md
51
+ - applescript/exportation.scpt
52
+ - bin/exportation
53
+ - lib/exportation.rb
54
+ homepage: https://github.com/joshdholtz/fastlane-env-lanes
55
+ licenses:
56
+ - MIT
57
+ metadata: {}
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubyforge_project:
74
+ rubygems_version: 2.2.2
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: CLI tool of easy exporting, encrypting, and decrypting of certificates and
78
+ private keys
79
+ test_files: []
80
+ has_rdoc: