ruby_easy_rsa 0.10.0.pre.7 → 0.10.0.pre.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -0
  3. data/Gemfile.lock +50 -13
  4. data/Rakefile +83 -46
  5. data/lib/ruby_easy_rsa/commands/base.rb +16 -18
  6. data/lib/ruby_easy_rsa/commands/build_ca.rb +3 -2
  7. data/lib/ruby_easy_rsa/commands/build_client_full.rb +3 -2
  8. data/lib/ruby_easy_rsa/commands/build_client_server_full.rb +3 -2
  9. data/lib/ruby_easy_rsa/commands/build_server_full.rb +3 -2
  10. data/lib/ruby_easy_rsa/commands/export_p12.rb +2 -0
  11. data/lib/ruby_easy_rsa/commands/export_p7.rb +2 -0
  12. data/lib/ruby_easy_rsa/commands/gen_crl.rb +3 -2
  13. data/lib/ruby_easy_rsa/commands/gen_dh.rb +3 -2
  14. data/lib/ruby_easy_rsa/commands/gen_req.rb +3 -2
  15. data/lib/ruby_easy_rsa/commands/import_req.rb +3 -2
  16. data/lib/ruby_easy_rsa/commands/init_pki.rb +2 -0
  17. data/lib/ruby_easy_rsa/commands/mixins/algorithm_config.rb +29 -8
  18. data/lib/ruby_easy_rsa/commands/mixins/copy_extensions_config.rb +13 -3
  19. data/lib/ruby_easy_rsa/commands/mixins/encrypt_key_config.rb +17 -3
  20. data/lib/ruby_easy_rsa/commands/mixins/extra_extensions_config.rb +26 -8
  21. data/lib/ruby_easy_rsa/commands/mixins/global_config.rb +94 -29
  22. data/lib/ruby_easy_rsa/commands/mixins/inline_credentials_file_config.rb +15 -3
  23. data/lib/ruby_easy_rsa/commands/mixins/netscape_extensions_config.rb +32 -9
  24. data/lib/ruby_easy_rsa/commands/mixins/ssl_config.rb +114 -35
  25. data/lib/ruby_easy_rsa/commands/mixins/sub_ca_config.rb +15 -4
  26. data/lib/ruby_easy_rsa/commands/renew.rb +3 -2
  27. data/lib/ruby_easy_rsa/commands/revoke.rb +2 -0
  28. data/lib/ruby_easy_rsa/commands/set_ec_pass.rb +2 -0
  29. data/lib/ruby_easy_rsa/commands/set_rsa_pass.rb +2 -0
  30. data/lib/ruby_easy_rsa/commands/show_ca.rb +2 -0
  31. data/lib/ruby_easy_rsa/commands/show_cert.rb +2 -0
  32. data/lib/ruby_easy_rsa/commands/show_req.rb +2 -0
  33. data/lib/ruby_easy_rsa/commands/sign_req.rb +3 -2
  34. data/lib/ruby_easy_rsa/commands/update_db.rb +3 -2
  35. data/lib/ruby_easy_rsa/commands/upgrade.rb +3 -2
  36. data/lib/ruby_easy_rsa/commands.rb +3 -2
  37. data/lib/ruby_easy_rsa/version.rb +3 -1
  38. data/lib/ruby_easy_rsa.rb +2 -0
  39. data/ruby_easy_rsa.gemspec +55 -0
  40. metadata +64 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a4184c8078440c5774eabca5d0b441b71a10dea3ac62d4304ffaa6ad2578e98
4
- data.tar.gz: 1eae0ef82936de9889be93ea552de1d3c18202e6c45605619ecf52fe36b74e72
3
+ metadata.gz: cc332f19eb98633977ed1bf7c65d9e33f2f17d8f40b5fcc55c8cc3a134553781
4
+ data.tar.gz: a1aec57346382357cde9aeaea502a86e566890aaac4e3824ff03811d1adc3ec7
5
5
  SHA512:
6
- metadata.gz: 66c45c2a0f2e13bc051f26528fc6d3e0cbdebd2781a9e27a604917903364a57d224935615e64e16ddf72035120395f8ff4a987390b32bef4c10ccfd9ae25615a
7
- data.tar.gz: ac0266512e2f934ea177cf5a6ea3b3c90ea445d6357c41b568e4d334c9aa32a32fe8dd71e30e1f4de4c17de5197f9b6f243186904294519d78c6c6dcb836db1f
6
+ metadata.gz: fe98bd2c123b28a05b3c2aaa117918dc2e263c59504a5dc152a4d435b5717682a70d01bdf85cbca53379eca7fe8399fe4bfd89093c5bfbd73e77d844e8f8af93
7
+ data.tar.gz: e4d1e0c6ae6abb3c2cff96526740cae4575aa935883f97579cc40c834f62579b4bd3499c66148f65975fd576ad8575d4ebff721520c3063dcdf17458d217714c
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in ruby_fly.gemspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby_easy_rsa (0.10.0.pre.7)
4
+ ruby_easy_rsa (0.10.0.pre.9)
5
5
  lino (~> 3.0)
6
6
 
7
7
  GEM
@@ -14,9 +14,11 @@ GEM
14
14
  tzinfo (~> 2.0)
15
15
  addressable (2.8.0)
16
16
  public_suffix (>= 2.0.2, < 5.0)
17
+ ast (2.4.2)
17
18
  colored2 (3.1.2)
18
19
  concurrent-ruby (1.1.9)
19
20
  diff-lcs (1.5.0)
21
+ docile (1.4.0)
20
22
  excon (0.92.0)
21
23
  faraday (1.10.0)
22
24
  faraday-em_http (~> 1.0)
@@ -46,6 +48,7 @@ GEM
46
48
  concurrent-ruby (~> 1.0)
47
49
  i18n (1.10.0)
48
50
  concurrent-ruby (~> 1.0)
51
+ json (2.6.2)
49
52
  lino (3.0.0)
50
53
  hamster (~> 3.0)
51
54
  open4 (~> 1.3)
@@ -55,7 +58,11 @@ GEM
55
58
  faraday (>= 0.9)
56
59
  sawyer (~> 0.8.0, >= 0.5.3)
57
60
  open4 (1.3.4)
61
+ parallel (1.22.1)
62
+ parser (3.1.2.1)
63
+ ast (~> 2.4.1)
58
64
  public_suffix (4.0.6)
65
+ rainbow (3.1.1)
59
66
  rake (13.0.6)
60
67
  rake_circle_ci (0.9.0)
61
68
  colored2 (~> 3.1)
@@ -77,28 +84,54 @@ GEM
77
84
  colored2 (~> 3.1)
78
85
  rake_factory (~> 0.23)
79
86
  sshkey (~> 2.0)
80
- rspec (3.11.0)
81
- rspec-core (~> 3.11.0)
82
- rspec-expectations (~> 3.11.0)
83
- rspec-mocks (~> 3.11.0)
84
- rspec-core (3.11.0)
85
- rspec-support (~> 3.11.0)
86
- rspec-expectations (3.11.0)
87
+ regexp_parser (2.6.0)
88
+ rexml (3.2.5)
89
+ rspec (3.12.0)
90
+ rspec-core (~> 3.12.0)
91
+ rspec-expectations (~> 3.12.0)
92
+ rspec-mocks (~> 3.12.0)
93
+ rspec-core (3.12.0)
94
+ rspec-support (~> 3.12.0)
95
+ rspec-expectations (3.12.0)
87
96
  diff-lcs (>= 1.2.0, < 2.0)
88
- rspec-support (~> 3.11.0)
89
- rspec-mocks (3.11.0)
97
+ rspec-support (~> 3.12.0)
98
+ rspec-mocks (3.12.0)
90
99
  diff-lcs (>= 1.2.0, < 2.0)
91
- rspec-support (~> 3.11.0)
92
- rspec-support (3.11.0)
100
+ rspec-support (~> 3.12.0)
101
+ rspec-support (3.12.0)
102
+ rubocop (1.37.1)
103
+ json (~> 2.3)
104
+ parallel (~> 1.10)
105
+ parser (>= 3.1.2.1)
106
+ rainbow (>= 2.2.2, < 4.0)
107
+ regexp_parser (>= 1.8, < 3.0)
108
+ rexml (>= 3.2.5, < 4.0)
109
+ rubocop-ast (>= 1.23.0, < 2.0)
110
+ ruby-progressbar (~> 1.7)
111
+ unicode-display_width (>= 1.4.0, < 3.0)
112
+ rubocop-ast (1.23.0)
113
+ parser (>= 3.1.1.0)
114
+ rubocop-rake (0.6.0)
115
+ rubocop (~> 1.0)
116
+ rubocop-rspec (2.14.2)
117
+ rubocop (~> 1.33)
118
+ ruby-progressbar (1.11.0)
93
119
  ruby2_keywords (0.0.5)
94
120
  ruby_gpg2 (0.8.0)
95
121
  lino (>= 1.5)
96
122
  sawyer (0.8.2)
97
123
  addressable (>= 2.3.5)
98
124
  faraday (> 0.8, < 2.0)
125
+ simplecov (0.21.2)
126
+ docile (~> 1.1)
127
+ simplecov-html (~> 0.11)
128
+ simplecov_json_formatter (~> 0.1)
129
+ simplecov-html (0.12.3)
130
+ simplecov_json_formatter (0.1.4)
99
131
  sshkey (2.0.0)
100
132
  tzinfo (2.0.4)
101
133
  concurrent-ruby (~> 1.0)
134
+ unicode-display_width (2.3.0)
102
135
 
103
136
  PLATFORMS
104
137
  arm64-darwin-21
@@ -113,7 +146,11 @@ DEPENDENCIES
113
146
  rake_gpg
114
147
  rake_ssh
115
148
  rspec
149
+ rubocop
150
+ rubocop-rake
151
+ rubocop-rspec
116
152
  ruby_easy_rsa!
153
+ simplecov
117
154
 
118
155
  BUNDLED WITH
119
- 2.3.9
156
+ 2.3.24
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'yaml'
2
4
  require 'rake_circle_ci'
3
5
  require 'rake_github'
@@ -5,17 +7,26 @@ require 'rake_ssh'
5
7
  require 'rake_gpg'
6
8
  require 'securerandom'
7
9
  require 'rspec/core/rake_task'
10
+ require 'rubocop/rake_task'
8
11
 
9
- task :default => :spec
10
-
11
- RSpec::Core::RakeTask.new(:spec)
12
+ task default: %i[
13
+ library:fix
14
+ test:unit
15
+ ]
12
16
 
13
17
  namespace :encryption do
18
+ namespace :directory do
19
+ desc 'Ensure CI secrets directory exists.'
20
+ task :ensure do
21
+ FileUtils.mkdir_p('config/secrets/ci')
22
+ end
23
+ end
24
+
14
25
  namespace :passphrase do
15
- task :generate do
16
- File.open('config/secrets/ci/encryption.passphrase', 'w') do |f|
17
- f.write(SecureRandom.base64(36))
18
- end
26
+ desc 'Generate encryption passphrase used by CI.'
27
+ task generate: ['directory:ensure'] do
28
+ File.write('config/secrets/ci/encryption.passphrase',
29
+ SecureRandom.base64(36))
19
30
  end
20
31
  end
21
32
  end
@@ -23,85 +34,111 @@ end
23
34
  namespace :keys do
24
35
  namespace :deploy do
25
36
  RakeSSH.define_key_tasks(
26
- path: 'config/secrets/ci/',
27
- comment: 'maintainers@infrablocks.io')
37
+ path: 'config/secrets/ci/',
38
+ comment: 'maintainers@infrablocks.io'
39
+ )
28
40
  end
29
41
 
30
42
  namespace :gpg do
31
43
  RakeGPG.define_generate_key_task(
32
- output_directory: 'config/secrets/ci',
33
- name_prefix: 'gpg',
34
- owner_name: 'InfraBlocks Maintainers',
35
- owner_email: 'maintainers@infrablocks.io',
36
- owner_comment: 'ruby_easy_rsa CI Key')
44
+ output_directory: 'config/secrets/ci',
45
+ name_prefix: 'gpg',
46
+ owner_name: 'InfraBlocks Maintainers',
47
+ owner_email: 'maintainers@infrablocks.io',
48
+ owner_comment: 'ruby_easy_rsa CI Key'
49
+ )
37
50
  end
38
51
  end
39
52
 
53
+ namespace :secrets do
54
+ desc 'Regenerate all generatable secrets.'
55
+ task regenerate: %w[
56
+ encryption:passphrase:generate
57
+ keys:deploy:generate
58
+ keys:gpg:generate
59
+ ]
60
+ end
61
+
62
+ RuboCop::RakeTask.new
63
+
64
+ namespace :library do
65
+ desc 'Run all checks of the library'
66
+ task check: [:rubocop]
67
+
68
+ desc 'Attempt to automatically fix issues with the library'
69
+ task fix: [:'rubocop:autocorrect']
70
+ end
71
+
72
+ namespace :test do
73
+ RSpec::Core::RakeTask.new(:unit)
74
+ end
75
+
40
76
  RakeCircleCI.define_project_tasks(
41
- namespace: :circle_ci,
42
- project_slug: 'github/infrablocks/ruby_easy_rsa'
77
+ namespace: :circle_ci,
78
+ project_slug: 'github/infrablocks/ruby_easy_rsa'
43
79
  ) do |t|
44
80
  circle_ci_config =
45
- YAML.load_file('config/secrets/circle_ci/config.yaml')
81
+ YAML.load_file('config/secrets/circle_ci/config.yaml')
46
82
 
47
- t.api_token = circle_ci_config["circle_ci_api_token"]
83
+ t.api_token = circle_ci_config['circle_ci_api_token']
48
84
  t.environment_variables = {
49
- ENCRYPTION_PASSPHRASE:
50
- File.read('config/secrets/ci/encryption.passphrase')
51
- .chomp
85
+ ENCRYPTION_PASSPHRASE:
86
+ File.read('config/secrets/ci/encryption.passphrase')
87
+ .chomp
52
88
  }
53
89
  t.checkout_keys = []
54
90
  t.ssh_keys = [
55
- {
56
- hostname: "github.com",
57
- private_key: File.read('config/secrets/ci/ssh.private')
58
- }
91
+ {
92
+ hostname: 'github.com',
93
+ private_key: File.read('config/secrets/ci/ssh.private')
94
+ }
59
95
  ]
60
96
  end
61
97
 
62
98
  RakeGithub.define_repository_tasks(
63
- namespace: :github,
64
- repository: 'infrablocks/ruby_easy_rsa',
99
+ namespace: :github,
100
+ repository: 'infrablocks/ruby_easy_rsa'
65
101
  ) do |t, args|
66
102
  github_config =
67
- YAML.load_file('config/secrets/github/config.yaml')
103
+ YAML.load_file('config/secrets/github/config.yaml')
68
104
 
69
- t.access_token = github_config["github_personal_access_token"]
105
+ t.access_token = github_config['github_personal_access_token']
70
106
  t.deploy_keys = [
71
- {
72
- title: 'CircleCI',
73
- public_key: File.read('config/secrets/ci/ssh.public')
74
- }
107
+ {
108
+ title: 'CircleCI',
109
+ public_key: File.read('config/secrets/ci/ssh.public')
110
+ }
75
111
  ]
76
112
  t.branch_name = args.branch_name
77
113
  t.commit_message = args.commit_message
78
114
  end
79
115
 
80
116
  namespace :pipeline do
81
- task :prepare => [
82
- :'circle_ci:project:follow',
83
- :'circle_ci:env_vars:ensure',
84
- :'circle_ci:checkout_keys:ensure',
85
- :'circle_ci:ssh_keys:ensure',
86
- :'github:deploy_keys:ensure'
117
+ desc 'Prepare CircleCI Pipeline'
118
+ task prepare: %i[
119
+ circle_ci:project:follow
120
+ circle_ci:env_vars:ensure
121
+ circle_ci:checkout_keys:ensure
122
+ circle_ci:ssh_keys:ensure
123
+ github:deploy_keys:ensure
87
124
  ]
88
125
  end
89
126
 
90
127
  namespace :version do
91
- desc "Bump version for specified type (pre, major, minor, patch)"
128
+ desc 'Bump version for specified type (pre, major, minor, patch)'
92
129
  task :bump, [:type] do |_, args|
93
130
  bump_version_for(args.type)
94
131
  end
95
132
  end
96
133
 
97
- desc "Release gem"
134
+ desc 'Release gem'
98
135
  task :release do
99
- sh "gem release --tag --push"
136
+ sh 'gem release --tag --push'
100
137
  end
101
138
 
102
139
  def bump_version_for(version_type)
103
- sh "gem bump --version #{version_type} " +
104
- "&& bundle install " +
105
- "&& export LAST_MESSAGE=\"$(git log -1 --pretty=%B)\" " +
106
- "&& git commit -a --amend -m \"${LAST_MESSAGE} [ci skip]\""
140
+ sh "gem bump --version #{version_type} " \
141
+ '&& bundle install ' \
142
+ '&& export LAST_MESSAGE="$(git log -1 --pretty=%B)" ' \
143
+ '&& git commit -a --amend -m "${LAST_MESSAGE} [ci skip]"'
107
144
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'lino'
2
4
 
3
5
  module RubyEasyRSA
@@ -14,42 +16,38 @@ module RubyEasyRSA
14
16
  end
15
17
 
16
18
  def stdout
17
- STDOUT
19
+ $stdout
18
20
  end
19
21
 
20
22
  def stderr
21
- STDERR
23
+ $stderr
22
24
  end
23
25
 
24
26
  def execute(opts = {})
25
- builder = instantiate_builder
26
-
27
27
  do_before(opts)
28
- builder = configure_command(builder, opts)
29
- builder
30
- .build
31
- .execute(
32
- stdin: stdin,
33
- stdout: stdout,
34
- stderr: stderr)
28
+ configure_command(instantiate_builder, opts)
29
+ .build
30
+ .execute(
31
+ stdin: stdin,
32
+ stdout: stdout,
33
+ stderr: stderr
34
+ )
35
35
  do_after(opts)
36
36
  end
37
37
 
38
38
  def instantiate_builder
39
39
  Lino::CommandLineBuilder
40
- .for_command(binary)
41
- .with_option_separator('=')
40
+ .for_command(binary)
41
+ .with_option_separator('=')
42
42
  end
43
43
 
44
- def do_before(opts)
45
- end
44
+ def do_before(_); end
46
45
 
47
- def configure_command(builder, opts)
46
+ def configure_command(builder, _opts)
48
47
  builder
49
48
  end
50
49
 
51
- def do_after(opts)
52
- end
50
+ def do_after(_); end
53
51
  end
54
52
  end
55
53
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'lino'
2
4
 
3
5
  require_relative 'base'
@@ -19,8 +21,7 @@ module RubyEasyRSA
19
21
 
20
22
  builder = builder.with_subcommand('build-ca')
21
23
  builder = builder.with_argument('subca') if sub_ca
22
- builder = super(builder, opts)
23
- builder
24
+ super(builder, opts)
24
25
  end
25
26
  end
26
27
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'lino'
2
4
 
3
5
  require_relative 'base'
@@ -29,8 +31,7 @@ module RubyEasyRSA
29
31
 
30
32
  builder = builder.with_subcommand('build-client-full')
31
33
  builder = builder.with_argument(filename_base)
32
- builder = super(builder, opts)
33
- builder
34
+ super(builder, opts)
34
35
  end
35
36
  end
36
37
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'lino'
2
4
 
3
5
  require_relative 'base'
@@ -29,8 +31,7 @@ module RubyEasyRSA
29
31
 
30
32
  builder = builder.with_subcommand('build-clientServer-full')
31
33
  builder = builder.with_argument(filename_base)
32
- builder = super(builder, opts)
33
- builder
34
+ super(builder, opts)
34
35
  end
35
36
  end
36
37
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'lino'
2
4
 
3
5
  require_relative 'base'
@@ -29,8 +31,7 @@ module RubyEasyRSA
29
31
 
30
32
  builder = builder.with_subcommand('build-server-full')
31
33
  builder = builder.with_argument(filename_base)
32
- builder = super(builder, opts)
33
- builder
34
+ super(builder, opts)
34
35
  end
35
36
  end
36
37
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'lino'
2
4
 
3
5
  require_relative 'base'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'lino'
2
4
 
3
5
  require_relative 'base'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'lino'
2
4
 
3
5
  require_relative 'base'
@@ -12,8 +14,7 @@ module RubyEasyRSA
12
14
 
13
15
  def configure_command(builder, opts)
14
16
  builder = builder.with_subcommand('gen-crl')
15
- builder = super(builder, opts)
16
- builder
17
+ super(builder, opts)
17
18
  end
18
19
  end
19
20
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'lino'
2
4
 
3
5
  require_relative 'base'
@@ -12,8 +14,7 @@ module RubyEasyRSA
12
14
 
13
15
  def configure_command(builder, opts)
14
16
  builder = super(builder, opts)
15
- builder = builder.with_subcommand('gen-dh')
16
- builder
17
+ builder.with_subcommand('gen-dh')
17
18
  end
18
19
  end
19
20
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'lino'
2
4
 
3
5
  require_relative 'base'
@@ -21,8 +23,7 @@ module RubyEasyRSA
21
23
 
22
24
  builder = builder.with_subcommand('gen-req')
23
25
  builder = builder.with_argument(filename_base)
24
- builder = super(builder, opts)
25
- builder
26
+ super(builder, opts)
26
27
  end
27
28
  end
28
29
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'lino'
2
4
 
3
5
  require_relative 'base'
@@ -17,8 +19,7 @@ module RubyEasyRSA
17
19
  builder = super(builder, opts)
18
20
  builder = builder.with_subcommand('import-req')
19
21
  builder = builder.with_argument(request_file)
20
- builder = builder.with_argument(filename_base)
21
- builder
22
+ builder.with_argument(filename_base)
22
23
  end
23
24
  end
24
25
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'lino'
2
4
 
3
5
  require_relative 'base'
@@ -1,19 +1,40 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RubyEasyRSA
2
4
  module Commands
3
5
  module Mixins
4
6
  module AlgorithmConfig
7
+ # rubocop:disable Style/RedundantAssignment
5
8
  def configure_command(builder, opts)
6
- algorithm = opts[:algorithm]
7
- curve = opts[:curve]
8
- ec_directory = opts[:ec_directory]
9
-
10
9
  builder = super(builder, opts)
11
- builder = builder.with_environment_variable(
12
- 'EASYRSA_EC_DIR', ec_directory) if ec_directory
13
- builder = builder.with_option('--use-algo', algorithm) if algorithm
14
- builder = builder.with_option('--curve', curve) if curve
10
+ builder = with_ec_directory(builder, opts[:ec_directory])
11
+ builder = with_algorithm(builder, opts[:algorithm])
12
+ builder = with_curve(builder, opts[:curve])
15
13
  builder
16
14
  end
15
+ # rubocop:enable Style/RedundantAssignment
16
+
17
+ private
18
+
19
+ def with_ec_directory(builder, ec_directory)
20
+ return builder unless ec_directory
21
+
22
+ builder.with_environment_variable(
23
+ 'EASYRSA_EC_DIR', ec_directory
24
+ )
25
+ end
26
+
27
+ def with_algorithm(builder, algorithm)
28
+ return builder unless algorithm
29
+
30
+ builder.with_option('--use-algo', algorithm)
31
+ end
32
+
33
+ def with_curve(builder, curve)
34
+ return builder unless curve
35
+
36
+ builder.with_option('--curve', curve)
37
+ end
17
38
  end
18
39
  end
19
40
  end
@@ -1,14 +1,24 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RubyEasyRSA
2
4
  module Commands
3
5
  module Mixins
4
6
  module CopyExtensionsConfig
7
+ # rubocop:disable Style/RedundantAssignment
5
8
  def configure_command(builder, opts)
6
- copy_extensions = opts[:copy_extensions]
7
-
8
9
  builder = super(builder, opts)
9
- builder = builder.with_flag('--copy-ext') if copy_extensions
10
+ builder = with_copy_extensions(builder, opts[:copy_extensions])
10
11
  builder
11
12
  end
13
+ # rubocop:enable Style/RedundantAssignment
14
+
15
+ private
16
+
17
+ def with_copy_extensions(builder, copy_extensions)
18
+ return builder unless copy_extensions
19
+
20
+ builder.with_flag('--copy-ext')
21
+ end
12
22
  end
13
23
  end
14
24
  end
@@ -1,14 +1,28 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RubyEasyRSA
2
4
  module Commands
3
5
  module Mixins
4
6
  module EncryptKeyConfig
7
+ # rubocop:disable Style/RedundantAssignment
5
8
  def configure_command(builder, opts)
6
- encrypt_key = opts[:encrypt_key].nil? ? true : opts[:encrypt_key]
7
-
8
9
  builder = super(builder, opts)
9
- builder = builder.with_argument('nopass') unless encrypt_key
10
+ builder = with_encrypt_key(builder, encrypt_key(opts))
10
11
  builder
11
12
  end
13
+ # rubocop:enable Style/RedundantAssignment
14
+
15
+ private
16
+
17
+ def encrypt_key(opts)
18
+ opts[:encrypt_key].nil? ? true : opts[:encrypt_key]
19
+ end
20
+
21
+ def with_encrypt_key(builder, encrypt_key)
22
+ return builder if encrypt_key
23
+
24
+ builder.with_argument('nopass')
25
+ end
12
26
  end
13
27
  end
14
28
  end