ovpn-key 1.2.1 → 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 +26 -20
- data/defaults/ovpn-key.yml +1 -1
- 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
|
@@ -185,25 +185,27 @@ if File.exist? 'openssl.ini'
|
|
|
185
185
|
warn 'WARNING: openssl.ini file is not used anymore. you can remove it'
|
|
186
186
|
end
|
|
187
187
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
188
|
+
unless options[:init]
|
|
189
|
+
phase_out = nil
|
|
190
|
+
unless ENCRYPT.casecmp? 'AES256'
|
|
191
|
+
warn "WARNING: your CA uses #{ENCRYPT}, not AES256"
|
|
192
|
+
phase_out = true
|
|
193
|
+
end
|
|
194
|
+
unless DIGEST&.match?(/\Asha(384|512)\z/i)
|
|
195
|
+
warn "WARNING: your CA uses #{DIGEST}; SHA384 or SHA512 are recommended instead"
|
|
196
|
+
phase_out = true
|
|
197
|
+
end
|
|
198
|
+
if KEY_TYPE && !KEY_TYPE&.match?(/\A(secp(384|521)r1|ML-DSA-87)\z/i)
|
|
199
|
+
warn "WARNING: your CA uses #{KEY_TYPE}, we recommend using secp384r1, secp521r1, ML-DSA-87 or RSA"
|
|
200
|
+
phase_out = true
|
|
201
|
+
end
|
|
202
|
+
if !KEY_TYPE && KEY_SIZE < 3072
|
|
203
|
+
warn "WARNING: your CA uses #{KEY_SIZE}-bit keys, 3072 is a recommended minimum"
|
|
204
|
+
phase_out = true
|
|
205
|
+
end
|
|
206
|
+
if phase_out
|
|
207
|
+
warn "WARNING: it's recommended to phase out this deployment and start afresh with better security"
|
|
208
|
+
end
|
|
207
209
|
end
|
|
208
210
|
|
|
209
211
|
if options[:generate_ca]
|
|
@@ -213,7 +215,7 @@ if options[:generate_ca]
|
|
|
213
215
|
sign_key('ca', CN_CA, ca_pass)
|
|
214
216
|
gen_crl(ca_pass)
|
|
215
217
|
rescue Interrupt, SystemExit
|
|
216
|
-
cleanup 'ca' # delete the CA
|
|
218
|
+
cleanup 'ca' # delete the CA if it's not complete
|
|
217
219
|
abort_on_interrupted
|
|
218
220
|
end
|
|
219
221
|
end
|
|
@@ -228,14 +230,17 @@ if options[:generate_static]
|
|
|
228
230
|
exe "#{OPENVPN} --genkey --secret ta.key"
|
|
229
231
|
end
|
|
230
232
|
if options[:generate_server]
|
|
233
|
+
check_ca
|
|
231
234
|
passphrase = passphrase(options[:no_password], options[:generate_server])
|
|
232
235
|
gen_and_sign('server', options[:generate_server], passphrase)
|
|
233
236
|
end
|
|
234
237
|
if options[:generate_client]
|
|
238
|
+
check_ca
|
|
235
239
|
passphrase = passphrase(options[:no_password], options[:generate_client])
|
|
236
240
|
gen_and_sign('client', options[:generate_client], passphrase)
|
|
237
241
|
end
|
|
238
242
|
if options[:generate_zip]
|
|
243
|
+
check_ca
|
|
239
244
|
ovpn_files = Dir['*.ovpn']
|
|
240
245
|
case ovpn_files.length
|
|
241
246
|
when 1
|
|
@@ -263,5 +268,6 @@ if options[:generate_zip]
|
|
|
263
268
|
end
|
|
264
269
|
end
|
|
265
270
|
if options[:revoke]
|
|
271
|
+
check_ca
|
|
266
272
|
revoke(options[:revoke])
|
|
267
273
|
end
|
data/defaults/ovpn-key.yml
CHANGED
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