exportation 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/exportation.rb +82 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c139c57094c0c7f634a9afda6e167df8b0c643cd
|
4
|
+
data.tar.gz: e7249d12f8a456ffbbc20272b41558094b0d5e0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9797508901d588ad634cf7d83e9a64afb1062ee1cc99f21e56bc423c495e299d71b79dd909c60ef14b129e501d87f7d105a4d6dca4fc3c1b48b35a7666b7f1e3
|
7
|
+
data.tar.gz: cbc708adb054e6e337fc8d47d1bbbcd0eaae6546cc2cb368403d3660e2f572576bf0ee53749801ab678391981357c583701c6920a7a4f5b00ea6d0407c7126d3
|
data/lib/exportation.rb
CHANGED
@@ -94,4 +94,86 @@ module Exportation
|
|
94
94
|
|
95
95
|
end
|
96
96
|
|
97
|
+
class Keychain
|
98
|
+
|
99
|
+
attr_accessor :path, :password
|
100
|
+
|
101
|
+
def initialize(options)
|
102
|
+
@path = options[:path]
|
103
|
+
@password = options[:password]
|
104
|
+
end
|
105
|
+
|
106
|
+
def self.find_or_create_keychain(name, password, output_directory='./')
|
107
|
+
path = chain_path(name, output_directory)
|
108
|
+
|
109
|
+
unless File.exists? path
|
110
|
+
`security create-keychain -p '#{password}' #{path}`
|
111
|
+
end
|
112
|
+
|
113
|
+
Keychain.new(path: path, password: password)
|
114
|
+
end
|
115
|
+
|
116
|
+
def self.login_keychain(password)
|
117
|
+
path = `security login-keychain`.strip
|
118
|
+
Keychain.new(path: path, password: password)
|
119
|
+
end
|
120
|
+
|
121
|
+
def self.list_keychains
|
122
|
+
# Gets a list of all the user's keychains in an array
|
123
|
+
# The keychain are paths wrapped in double quotes
|
124
|
+
(`security list-keychains -d user`).scan(/(?:\w|"[^"]*")+/)
|
125
|
+
end
|
126
|
+
|
127
|
+
def import_certificate(cer_path)
|
128
|
+
# Imports a certificate into the keychain
|
129
|
+
`security import #{cer_path} -k #{@path} -T /usr/bin/codesign`
|
130
|
+
end
|
131
|
+
|
132
|
+
def import_private_key(key_path, password)
|
133
|
+
# Imports a private key into the keychain
|
134
|
+
`security import #{key_path} -k #{@path} -P '#{password}' -T /usr/bin/codesign`
|
135
|
+
end
|
136
|
+
|
137
|
+
def unlock!(seconds=3600)
|
138
|
+
# Unlocks the keychain
|
139
|
+
`security unlock-keychain -p '#{@password}' #{@path}`
|
140
|
+
`security -v set-keychain-settings -t #{seconds} -l #{@path}`
|
141
|
+
end
|
142
|
+
|
143
|
+
def add_to_keychain_list!
|
144
|
+
# Adds the keychain to the search list
|
145
|
+
keychains = (Keychain.list_keychains - ["\"#{@path}\""]).join(' ')
|
146
|
+
`security list-keychains -d user -s #{keychains} \"#{@path}\"`
|
147
|
+
end
|
148
|
+
|
149
|
+
def remove_keychain_from_list!
|
150
|
+
# Removes the keychain from the search list
|
151
|
+
keychains = (Keychain.list_keychains - ["\"#{@path}\""]).join(' ')
|
152
|
+
`security list-keychains -d user -s #{keychains}`
|
153
|
+
end
|
154
|
+
|
155
|
+
private
|
156
|
+
|
157
|
+
def self.chain_path(name, output_directory='./')
|
158
|
+
output_directory = File.expand_path output_directory
|
159
|
+
File.join(output_directory, "#{name}.keychain")
|
160
|
+
end
|
161
|
+
|
162
|
+
# Creates keychain with cert and private key (this is how Xcode knows how to sign things)
|
163
|
+
# sh "security create-keychain -p '#{keychain_password}' #{chain_path}"
|
164
|
+
# sh "security import ./Certs/apple.cer -k #{chain_path} -T /usr/bin/codesign"
|
165
|
+
# sh "security import ../build/unenc/dist.cer -k #{chain_path} -T /usr/bin/codesign"
|
166
|
+
# sh "security import ../build/unenc/dist.p12 -k #{chain_path} -P '#{private_key_password}' -T /usr/bin/codesign"
|
167
|
+
|
168
|
+
# sh "security unlock-keychain -p '#{keychain_password}' #{chain_path}"
|
169
|
+
# sh "security -v set-keychain-settings -t 3600 -l #{chain_path}"
|
170
|
+
#
|
171
|
+
# # Add keychain to list (this is literally the key to getting this all working)
|
172
|
+
# sh "security list-keychains -d user -s #{ENV['ORIGINAL_KEYCHAINS']} \"#{chain_path}\""
|
173
|
+
|
174
|
+
# Reset keychains to what was originally set for user
|
175
|
+
# sh "security list-keychains -d user -s #{ENV['ORIGINAL_KEYCHAINS']}"
|
176
|
+
|
177
|
+
end
|
178
|
+
|
97
179
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exportation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Holtz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|