ovpn-key 1.1.4 → 1.1.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d7c9c65faa9894017f0452d5635b065a3caaa363ee7ded648200f46180a78102
4
- data.tar.gz: 7814a7ad2ead53e20b6c72be3e3eabef7abda62d70fb9e6fcafa4a6429b20215
3
+ metadata.gz: 8072a8287dcb1a2386df0d8f9a420aa7aeef64662ab9341afd23bc818f4c543b
4
+ data.tar.gz: 9be53d42013002c533eb87d1128167857897dbe12f12495ef91d17d7cbf7c8cc
5
5
  SHA512:
6
- metadata.gz: 62d5d6cb60f781a9936d78b5eedd33c4fa5e148561fcb2a1843f675ceffd1af4e8c17b83c2b3a3f02277f99065e1db71b6d1dbdbe7d27856618b92c9528ef1d3
7
- data.tar.gz: 27101a8464276930606d1b65825805eed56efecd28f56ace804ef37b67b28b0ef44bc962fef7f8b3564a79a8783ab4065e060d384bfde6afdcf6e0d15098b98d
6
+ metadata.gz: 8f49b1b5c2b6b6de6c9005d7b422a3d0e41aee06215cd499f633b334db7371e6082e92ecaa530fc58f96346fb781c9686a8464c610f448714e10dc8d882a2419
7
+ data.tar.gz: cdeec55d2f7ae554ef30a2904a884746fad11b0ee2929382d07e8954ba506dea51146aa38921d5b5a4d9593d5e2aa1e6daa991b4b273a95b0e30550ceb2f2f46
data/README.md CHANGED
@@ -24,7 +24,7 @@ Important: `ca.key` is the CA's private key. Protect it carefully and never dist
24
24
  Losing it means you can no longer issue certificates or generate updated CRLs for this CA.
25
25
 
26
26
  There's a flat directory with configuration, generated keys and metadata:
27
- * `ovpn-key.yml`: [configuration](https://github.com/chillum/ovpn-key/blob/master/defaults/ovpn-key.yml)
27
+ * `ovpn-key.yml`: [configuration](defaults/ovpn-key.yml)
28
28
  * `serial`: incremental counter
29
29
  * `crl.pem`: certificate revocation list, `crl-verify` in OpenVPN's config
30
30
  * `ca.crt`: public key for the CA
@@ -50,30 +50,10 @@ Generating a certificate with existing name will fail, no harm will be done.
50
50
  6. revoke a client certificate
51
51
  `ovpn-key --revoke alice`
52
52
 
53
- ### Switching from Easy-RSA
53
+ ### Existing certificates
54
54
 
55
- To import an existing CA instead of creating a new one, place the following files in the working directory:
56
-
57
- * `ca.crt`: CA certificate
58
- * `ca.key`: CA private key
59
- * `crl.pem`: if the existing CA has revoked certificates, preserve its CRL.
60
- Starting with a new CRL would lose the existing revocation information.
61
-
62
- Skip the `--ca` step.
63
-
64
- #### Certificate serial numbers
65
-
66
- If the existing CA uses sequential integer serial numbers, initialize the `serial` file with the serial number of the latest issued certificate. For example, if the latest certificate has serial number `2`, run `echo -n 2 > serial`
67
-
68
- If the existing CA uses random or non-sequential serial numbers (or serial numbers that cannot be represented as integers),
69
- you can omit this step. `ovpn-key` will initialize the counter and start issuing certificates from `1`.
70
-
71
- #### Revoking pre-existing certificates
72
-
73
- Existing certificates remain valid and can continue to be used.
74
-
75
- To revoke an existing certificate using `ovpn-key --revoke`, its `.crt` file must also be present in the working directory.
76
- For example, to revoke `alice`, place `alice.crt` there.
55
+ We recommend to start afresh with new better keys.
56
+ However, you may want to import the pre-existing CA to `ovpn-key`, see [docs](pre-existing-keys.md).
77
57
 
78
58
  ### --server
79
59
 
@@ -123,7 +103,7 @@ It will contain:
123
103
 
124
104
  ### Configuration
125
105
 
126
- It's just a single simple YAML file named [`ovpn-key.yml`](https://github.com/chillum/ovpn-key/blob/master/defaults/ovpn-key.yml).
106
+ It's just a single simple YAML file named [`ovpn-key.yml`](defaults/ovpn-key.yml).
127
107
 
128
108
  ovpn-key also processes `~/.ovpn-key.yml` file, it has only one possible setting:
129
109
  ```yaml
data/bin/ovpn-key CHANGED
@@ -16,53 +16,58 @@ SERIAL_FILE = 'serial'
16
16
 
17
17
  options = {}
18
18
  # rubocop:disable-next Metrics/BlockLength
19
- OptionParser.new do |opts|
20
- opts.banner = "Usage: #{File.basename $PROGRAM_NAME} <options> [--nopass]"
21
- opts.on('--init [directory]', 'Init a CA directory (defaults to current)') do |v|
22
- options[:init] = v || '.'
23
- end
24
- opts.on('--ca', 'Generate a CA (ca.crt)') do |v|
25
- check_crt('ca')
26
- options[:generate_ca] = v
27
- end
28
- opts.on('--dh', 'Generate a DH keyfile (dh.pem)') do |v|
29
- # it's safe to overwrite this file
30
- options[:generate_dh] = v
31
- end
32
- opts.on('--static', 'Generate OpenVPN static key (ta.key)') do |v|
33
- options[:generate_static] = v
34
- check_crt('ta')
35
- end
36
- opts.on('--server [name]', "Generate a server key (defaults to 'server')") do |v|
37
- options[:generate_server] = v || 'server'
38
- check_crt(options[:generate_server])
39
- end
40
- opts.on('--client [name]', 'Generate a client key and sign it') do |v|
41
- check_client(v)
42
- options[:generate_client] = v
43
- end
44
- opts.on('--zip [name]', 'Ditto plus pack it to ZIP with OpenVPN config') do |v|
45
- check_client(v)
46
- options[:generate_zip] = v
47
- end
48
- opts.on('--revoke [name]', "Revoke a certificate (using #{CRL_FILE}) and delete it") do |v|
49
- abort 'Please specify what certificate to revoke' unless v
50
- options[:revoke] = v
51
- end
52
- opts.on('--nopass', "Don't protect .key files with a password") do |v|
53
- options[:no_password] = v
54
- end
55
- end.parse!
19
+ begin
20
+ OptionParser.new do |opts|
21
+ opts.banner = "Usage: #{File.basename $PROGRAM_NAME} <options> [--nopass]"
22
+ opts.on('--init [directory]', 'Init a CA directory (defaults to current)') do |v|
23
+ options[:init] = v || '.'
24
+ end
25
+ opts.on('--ca', 'Generate a CA (ca.crt)') do |v|
26
+ check_crt('ca')
27
+ options[:generate_ca] = v
28
+ end
29
+ opts.on('--dh', 'Generate a DH keyfile (dh.pem)') do |v|
30
+ # it's safe to overwrite this file
31
+ options[:generate_dh] = v
32
+ end
33
+ opts.on('--static', 'Generate OpenVPN static key (ta.key)') do |v|
34
+ options[:generate_static] = v
35
+ check_crt('ta')
36
+ end
37
+ opts.on('--server [name]', "Generate a server key (defaults to 'server')") do |v|
38
+ options[:generate_server] = v || 'server'
39
+ check_crt(options[:generate_server])
40
+ end
41
+ opts.on('--client [name]', 'Generate a client key and sign it') do |v|
42
+ check_client(v)
43
+ options[:generate_client] = v
44
+ end
45
+ opts.on('--zip [name]', 'Ditto plus pack it to ZIP with OpenVPN config') do |v|
46
+ check_client(v)
47
+ options[:generate_zip] = v
48
+ end
49
+ opts.on('--revoke [name]', "Revoke a certificate (using #{CRL_FILE}) and delete it") do |v|
50
+ abort 'Please specify what certificate to revoke' unless v
51
+ abort "ERROR: cannot revoke ca.crt, it's the root cert" if v == 'ca'
52
+ options[:revoke] = v
53
+ end
54
+ opts.on('--nopass', "Don't protect .key files with a password") do |v|
55
+ options[:no_password] = v
56
+ end
57
+ end.parse!
58
+ rescue OptionParser::ParseError => e
59
+ usage e.message
60
+ end
56
61
  if ARGV.length.positive?
57
- abort "Error: invalid args: #{ARGV.join ' '}\nSee `#{File.basename $PROGRAM_NAME} -h` for help"
62
+ usage "invalid args: #{ARGV.join ' '}"
58
63
  end
59
64
  unless options[:init] || options[:generate_ca] || options[:generate_dh] || options[:generate_static] \
60
65
  || options[:generate_server] || options[:generate_client] || options[:generate_zip] || options[:revoke]
61
- abort "See `#{File.basename $PROGRAM_NAME} -h` for usage"
66
+ usage 'no action provided'
62
67
  end
63
68
  if options[:generate_client] && options[:generate_zip]
64
69
  # I assume that user likely wants one of them and is confused with usage
65
- abort 'There can be only one: --client or --zip'
70
+ abort 'ERROR: there can be only one: --client or --zip'
66
71
  end
67
72
 
68
73
  if options[:init]
data/lib/functions.rb CHANGED
@@ -2,15 +2,19 @@
2
2
 
3
3
  def check_crt(filename)
4
4
  %w[key crt].each {|ext|
5
- abort "#{filename}.#{ext} already exists, exiting" if File.exist? "#{filename}.#{ext}"
5
+ abort "#{filename}.#{ext} already exists, aborting" if File.exist? "#{filename}.#{ext}"
6
6
  }
7
7
  end
8
8
 
9
9
  def check_client(name)
10
- abort 'Error: client should have an alphanumeric name' unless name
10
+ abort 'ERROR: client should have an alphanumeric name' unless name
11
11
  check_crt(name)
12
12
  end
13
13
 
14
+ def usage(error)
15
+ abort "ERROR: #{error}\nSee `#{File.basename $PROGRAM_NAME} -h` for usage"
16
+ end
17
+
14
18
  def exe(cmd)
15
19
  system(cmd) || abort("error executing: #{cmd}")
16
20
  end
@@ -124,7 +128,7 @@ def revoke(certname)
124
128
  begin
125
129
  cert = OpenSSL::X509::Certificate.new(File.read("#{certname}.crt"))
126
130
  rescue Errno::ENOENT
127
- abort "#{certname}.crt doesn't exist"
131
+ abort "#{certname}.crt doesn't exist, aborting"
128
132
  end
129
133
  revoke = OpenSSL::X509::Revoked.new.tap {|rev|
130
134
  rev.serial = cert.serial
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- VERSION = '1.1.4'
3
+ VERSION = '1.1.5'
@@ -0,0 +1,25 @@
1
+ # Importing a pre-existing CA
2
+
3
+ To import an existing CA instead of creating a new one,
4
+ place the following files in the working directory:
5
+
6
+ * `ca.crt`: CA certificate
7
+ * `ca.key`: CA private key
8
+ * `crl.pem`: if the existing CA has revoked certificates, preserve its CRL.
9
+ Starting with a new CRL would lose the existing revocation information.
10
+
11
+ Skip the `--ca` step.
12
+
13
+ ## Certificate serial numbers
14
+
15
+ If the existing CA uses sequential integer serial numbers, initialize the `serial` file with the serial number of the latest issued certificate. For example, if the latest certificate has serial number `2`, run `echo -n 2 > serial`
16
+
17
+ If the existing CA uses random or non-sequential serial numbers (or serial numbers that cannot be represented as integers),
18
+ you can omit this step. `ovpn-key` will initialize the counter and start issuing certificates from `1`.
19
+
20
+ ## Revoking pre-existing certificates
21
+
22
+ Existing certificates remain valid and can continue to be used.
23
+
24
+ To revoke an existing certificate using `ovpn-key --revoke`, its `.crt` file must also be present in the working directory.
25
+ For example, to revoke `alice`, place `alice.crt` there.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ovpn-key
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vasily Korytov
@@ -45,6 +45,7 @@ files:
45
45
  - defaults/ovpn-key.yml
46
46
  - lib/functions.rb
47
47
  - lib/version.rb
48
+ - pre-existing-keys.md
48
49
  homepage: https://github.com/chillum/ovpn-key
49
50
  licenses:
50
51
  - Apache-2.0