exportation 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +64 -4
  3. data/bin/exportation +0 -4
  4. data/lib/exportation.rb +28 -9
  5. metadata +15 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c139c57094c0c7f634a9afda6e167df8b0c643cd
4
- data.tar.gz: e7249d12f8a456ffbbc20272b41558094b0d5e0c
3
+ metadata.gz: 0eb69604d7c56805983df50adaca88fd09073ba3
4
+ data.tar.gz: 0848757c3e31f1b16808165cf7ec91f86fd913c6
5
5
  SHA512:
6
- metadata.gz: 9797508901d588ad634cf7d83e9a64afb1062ee1cc99f21e56bc423c495e299d71b79dd909c60ef14b129e501d87f7d105a4d6dca4fc3c1b48b35a7666b7f1e3
7
- data.tar.gz: cbc708adb054e6e337fc8d47d1bbbcd0eaae6546cc2cb368403d3660e2f572576bf0ee53749801ab678391981357c583701c6920a7a4f5b00ea6d0407c7126d3
6
+ metadata.gz: 339cf3b94b9288cc9054b70279fb3fb4e0289890832117f5f88d4c62f31f40b4e2a0097ff1da5f20893c06ea31be72df9f80a545cc33c5e602d2192f8b139a64
7
+ data.tar.gz: b66e0c20cafac106853f1ad1dda6bfaa897e8074b4eaf8cf1a6a8e7a4a0592a2ec3773fe85b3071e7a9fe2818999ca5c7f08ec5817fac1c0f77651b63d9cabfd
data/README.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # exportation
2
- CLI tool of easy exporting, encrypting, and decrypting of certificates and private keys.
2
+ [![Twitter: @KauseFx](https://img.shields.io/badge/contact-@joshdholtz-blue.svg?style=flat)](https://twitter.com/joshdholtz)
3
+ [![License](http://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/joshdholtz/exportation/blob/master/LICENSE)
4
+ [![Gem](https://img.shields.io/gem/v/exportation.svg?style=flat)](http://rubygems.org/gems/exportation)
5
+ [![Build Status](https://img.shields.io/travis/joshdholtz/exportation/master.svg?style=flat)](https://travis-ci.org/joshdholtz/exportation)
6
+
7
+ CLI tool (and Ruby API) of easy exporting, encrypting, and decrypting of certificates and private keys. It can also add certificates and private keys to an existing or new keychain :grinning:
3
8
 
4
9
  **Important:** The `export` command will take control of your "Keychain Access" app so keep all hands off your computer while that command runs
5
10
 
@@ -19,7 +24,7 @@ Info Take all hands off your computer! exportation is going to take control of
19
24
  - Export **and** encrypt certificates **and** private keys **into** repos
20
25
  - CI tools (may need these to distrubute builds to Apple TestFlight Beta :apple:)
21
26
  - For other developers (for when you are on vacation and they need to make a distribution build :grimacing:)
22
-
27
+
23
28
  ### How
24
29
  - Makes use of AppleScript to control "Keychain Access"
25
30
  - Opens "Keychain Access"
@@ -39,7 +44,6 @@ Info Take all hands off your computer! exportation is going to take control of
39
44
 
40
45
  ### Features in progress
41
46
  - Integrate with [fastlane](https://github.com/KrauseFx/fastlane) :rocket:
42
- - Create a separate keychain with the certificates and private keys for use on CI systems :grinning:
43
47
 
44
48
  ### Caveats
45
49
  - Some phases of the script might run slow due to using AppleScript
@@ -66,7 +70,7 @@ gem install exportation
66
70
  ![](readme_assets/access.png)
67
71
  **You won't need to give Heroes, Script Editor, or Steam permissions for exportation** :wink:
68
72
 
69
- ## Commands
73
+ ## CLI Commands
70
74
  Exportation has three different commands: `export`, `encrypt`, and `decrypt`.
71
75
 
72
76
  ### Export from Keychain Access
@@ -87,6 +91,62 @@ exportation encrypt exported.cer exported.p12 --password dudethis
87
91
  exportation decrypt exported.cer.enc exported.p12.enc --password dudethis
88
92
  ```
89
93
 
94
+ ## Ruby API
95
+
96
+ ### Exportation::Export
97
+ ```ruby
98
+ Exportation::Export.new(
99
+ path: "/path/to/export/to",
100
+ filename: "base_exported_file_name", #dist.cer and dist.p12
101
+ name: "YourCompany LLC",
102
+ password: "shhhh"
103
+ ).run
104
+ ```
105
+
106
+ ### Exportation::Crypter
107
+
108
+ #### Encrypt
109
+ ```ruby
110
+ Exportation::Crypter.new(
111
+ files: ["dist.cer","dist.p12"],
112
+ password: "shhhh",
113
+ output: "./"
114
+ ).run :en
115
+ ```
116
+
117
+ #### Decrypt
118
+ ```ruby
119
+ Exportation::Crypter.new(
120
+ files: ["dist.cer.enc","dist.p12.enc"],
121
+ password: "shhhh",
122
+ output: "./"
123
+ ).run :de
124
+ ```
125
+
126
+ ### Exportation::Keychain
127
+ ```ruby
128
+ # Create keychain - name of chain, password, output directory
129
+ keychain = Exportation::Keychain.find_or_create_keychain('JoshChain', 'joshiscool', './example')
130
+
131
+ # Get login keychain
132
+ keychain = Exportation::Keychain.login_keychain("password")
133
+
134
+ # Import a certificate into keychain
135
+ keychain.import_certificate './example/dist.cer'
136
+
137
+ # Import a private key into keychain
138
+ keychain.import_private_key './example/dist.p12', 'da_password'
139
+
140
+ # Unlock keychain
141
+ keychain.unlock!
142
+
143
+ # Adds keychain to search list
144
+ keychain.add_to_keychain_list!
145
+
146
+ # Removes keychain from search list
147
+ keychain.remove_keychain_from_list!
148
+ ```
149
+
90
150
  ## Using the internals
91
151
 
92
152
  ### Compiling and running the AppleScript directly
@@ -39,10 +39,6 @@ class ExportationApplication
39
39
  options.password = ask("Password for private key (default: ''): ") unless options.password
40
40
  end
41
41
 
42
- options.path = './' if is_empty?(options.path)
43
- options.filename = 'exported' if is_empty?(options.filename)
44
- options.password = '' if is_empty?(options.password)
45
-
46
42
  raise "'name' is required" if is_empty?(options.name)
47
43
  log "Info".blue, "Take all hands off your computer! exportation is going to take control of 'Keychain Access'".blue
48
44
 
@@ -12,6 +12,10 @@ module Exportation
12
12
  File.join(gem_path, 'applescript', 'exportation.scpt')
13
13
  end
14
14
 
15
+ def self.is_empty?(str)
16
+ str.nil? || str.length == 0
17
+ end
18
+
15
19
  class Export
16
20
 
17
21
  attr_accessor :path, :filename, :name, :password
@@ -21,9 +25,20 @@ module Exportation
21
25
  @filename = options[:filename]
22
26
  @name = options[:name]
23
27
  @password = options[:password]
28
+
29
+ @path = './' if Exportation.is_empty?(@path)
30
+ @filename = 'exported' if Exportation.is_empty?(@filename)
31
+ @password = '' if Exportation.is_empty?(@password)
24
32
  end
25
33
 
26
34
  def run
35
+ bash = run_command
36
+ puts "Running: #{bash}"
37
+ `#{bash}`
38
+ end
39
+
40
+ def run_command
41
+ raise "name is required" if Exportation.is_empty?(@name)
27
42
 
28
43
  abs_path = File.expand_path path
29
44
  abs_path += '/' unless abs_path.end_with? '/'
@@ -32,11 +47,7 @@ module Exportation
32
47
  "\"#{abs_path}\" " +
33
48
  "\"#{filename}\" " +
34
49
  "\"#{name}\" " +
35
- "\"#{password}\" "
36
-
37
- puts "Running: #{bash}"
38
- `#{bash}`
39
-
50
+ "\"#{password}\""
40
51
  end
41
52
 
42
53
  end
@@ -52,6 +63,14 @@ module Exportation
52
63
  end
53
64
 
54
65
  def run(crypt, force = false)
66
+ run_commands(crypt, force).each do |bash|
67
+ puts "Running: #{bash}"
68
+ `#{bash}`
69
+ end
70
+ end
71
+
72
+ def run_commands(crypt, force = false)
73
+ raise "password is required" if Exportation.is_empty?(@password)
55
74
 
56
75
  unless force
57
76
  if crypt == :en
@@ -68,6 +87,7 @@ module Exportation
68
87
  end
69
88
 
70
89
  # Does the stuff
90
+ commands = []
71
91
  files.each do |file|
72
92
  file = './' + file unless file.start_with? '/'
73
93
  if File.exists? file
@@ -82,14 +102,13 @@ module Exportation
82
102
  output_file = output_file.gsub('.enc','')
83
103
  end
84
104
 
85
- bash = "openssl aes-256-cbc -k \"#{password}\" -in #{file} -out #{output_file} -a"
86
- puts "Running: #{bash}"
87
- `#{bash}`
105
+ commands << "openssl aes-256-cbc -k \"#{password}\" -in #{file} -out #{output_file} -a"
88
106
  else
89
- puts "File does not exist - #{file}"
107
+ raise "File does not exist - #{file}"
90
108
  end
91
109
  end
92
110
 
111
+ commands
93
112
  end
94
113
 
95
114
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exportation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Holtz
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.6'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  description: CLI tool of easy exporting, encrypting, and decrypting of certificates
70
84
  and private keys using Keychain Acess and openssl
71
85
  email: me@joshholtz.com