ovpn-key 1.2.2 → 1.2.3
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/bin/ovpn-key +4 -0
- data/lib/functions.rb +29 -0
- data/lib/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5a58f56fc5d8c35e9d3e43bdca07260535603ddac976c13a2a354c0a5c33034f
|
|
4
|
+
data.tar.gz: 8468e5bf92c69ef8ca1fabeceb45751f852246ea83db18c2b137065a6e3768ed
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ac5ae25b8c30b185b69e1b926b3408fcd29b97f19f8cc35d46790332d11e71f2e63812c46b82e7cfe60e253bae264761971d1d9e2aeaf1e597e8eef7876bb19d
|
|
7
|
+
data.tar.gz: a666144534a3b7fab5123e17b5a3c2ffdf12d8146ebd9e24237594e0df01f7964d3e8d8aad62354a7fa7d3720e8c11ff32183245d05a05291ff41187a09a8f45
|
data/bin/ovpn-key
CHANGED
|
@@ -230,14 +230,17 @@ if options[:generate_static]
|
|
|
230
230
|
exe "#{OPENVPN} --genkey --secret ta.key"
|
|
231
231
|
end
|
|
232
232
|
if options[:generate_server]
|
|
233
|
+
check_ca
|
|
233
234
|
passphrase = passphrase(options[:no_password], options[:generate_server])
|
|
234
235
|
gen_and_sign('server', options[:generate_server], passphrase)
|
|
235
236
|
end
|
|
236
237
|
if options[:generate_client]
|
|
238
|
+
check_ca
|
|
237
239
|
passphrase = passphrase(options[:no_password], options[:generate_client])
|
|
238
240
|
gen_and_sign('client', options[:generate_client], passphrase)
|
|
239
241
|
end
|
|
240
242
|
if options[:generate_zip]
|
|
243
|
+
check_ca
|
|
241
244
|
ovpn_files = Dir['*.ovpn']
|
|
242
245
|
case ovpn_files.length
|
|
243
246
|
when 1
|
|
@@ -265,5 +268,6 @@ if options[:generate_zip]
|
|
|
265
268
|
end
|
|
266
269
|
end
|
|
267
270
|
if options[:revoke]
|
|
271
|
+
check_ca
|
|
268
272
|
revoke(options[:revoke])
|
|
269
273
|
end
|
data/lib/functions.rb
CHANGED
|
@@ -11,6 +11,12 @@ def check_client(name)
|
|
|
11
11
|
check_crt(name)
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
+
def check_ca
|
|
15
|
+
return if File.exist?('ca.crt') && (File.exist? 'ca.key')
|
|
16
|
+
|
|
17
|
+
abort "ERROR: no `ca.crt` or `ca.key`. Run `#{File.basename $PROGRAM_NAME} --ca` first."
|
|
18
|
+
end
|
|
19
|
+
|
|
14
20
|
def usage(error)
|
|
15
21
|
abort "ERROR: #{error}\nSee `#{File.basename $PROGRAM_NAME} -h` for usage"
|
|
16
22
|
end
|
|
@@ -59,6 +65,7 @@ end
|
|
|
59
65
|
def gen_and_sign(type, certname, password)
|
|
60
66
|
gen_key(certname, password)
|
|
61
67
|
sign_key(type, certname, password)
|
|
68
|
+
create_crl
|
|
62
69
|
rescue Interrupt, SystemExit
|
|
63
70
|
cleanup certname # clean up the key if it wasn't signed due to user's interrupt
|
|
64
71
|
abort_on_interrupted
|
|
@@ -142,7 +149,9 @@ end
|
|
|
142
149
|
|
|
143
150
|
# rubocop:disable-next Metrics/AbcSize,Metrics/MethodLength
|
|
144
151
|
def revoke(certname)
|
|
152
|
+
create_crl
|
|
145
153
|
crl = OpenSSL::X509::CRL.new(File.read(CRL_FILE))
|
|
154
|
+
|
|
146
155
|
begin
|
|
147
156
|
cert = OpenSSL::X509::Certificate.new(File.read("#{certname}.crt"))
|
|
148
157
|
rescue Errno::ENOENT
|
|
@@ -168,12 +177,31 @@ def cleanup(certname)
|
|
|
168
177
|
}
|
|
169
178
|
end
|
|
170
179
|
|
|
180
|
+
# rubocop:disable-next Metrics/MethodLength
|
|
181
|
+
def create_crl
|
|
182
|
+
return if File.exist? CRL_FILE
|
|
183
|
+
|
|
184
|
+
ca_pass = ''
|
|
185
|
+
begin
|
|
186
|
+
begin
|
|
187
|
+
OpenSSL::PKey.read File.read('ca.key'), ca_pass
|
|
188
|
+
rescue OpenSSL::PKey::PKeyError
|
|
189
|
+
ca_pass = ask_password('ca')
|
|
190
|
+
end
|
|
191
|
+
rescue OpenSSL::PKey::PKeyError
|
|
192
|
+
retry
|
|
193
|
+
end
|
|
194
|
+
gen_crl(ca_pass)
|
|
195
|
+
end
|
|
196
|
+
|
|
171
197
|
def gen_crl(ca_pass)
|
|
172
198
|
return if File.exist? CRL_FILE
|
|
173
199
|
|
|
174
200
|
crl = OpenSSL::X509::CRL.new
|
|
175
201
|
crl.issuer = OpenSSL::X509::Name.new([['CN', CN_CA]] + REQ.to_a)
|
|
176
202
|
update_crl(crl, ca_pass)
|
|
203
|
+
|
|
204
|
+
warn "Created file: #{CRL_FILE}"
|
|
177
205
|
end
|
|
178
206
|
|
|
179
207
|
def update_crl(crl, ca_pass)
|
|
@@ -193,6 +221,7 @@ end
|
|
|
193
221
|
def new_serial
|
|
194
222
|
File.read(SERIAL_FILE).to_i + 1
|
|
195
223
|
rescue Errno::ENOENT
|
|
224
|
+
warn "Created file: #{SERIAL_FILE}"
|
|
196
225
|
1
|
|
197
226
|
end
|
|
198
227
|
|
data/lib/version.rb
CHANGED