kybus-ssl 0.2.0 → 0.3.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/kybus/ssl/certificate.rb +30 -2
- data/lib/kybus/ssl/cli/add_ca.rb +12 -14
- data/lib/kybus/ssl/cli/add_certificate.rb +8 -14
- data/lib/kybus/ssl/cli/base_command.rb +6 -0
- data/lib/kybus/ssl/cli/build.rb +12 -0
- data/lib/kybus/ssl/cli/init.rb +59 -115
- data/lib/kybus/ssl/cli/update_crl.rb +12 -0
- data/lib/kybus/ssl/cli.rb +1 -1
- data/lib/kybus/ssl/configuration.rb +13 -2
- data/lib/kybus/ssl/inventory.rb +30 -0
- data/lib/kybus/ssl/version.rb +1 -1
- metadata +10 -96
- data/bin/kybssl +0 -90
- data/lib/kybus/ssl/cli/revoke_certificate.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b608e41afe35bae9646207f98879a12ab73e3754ccb344115729f2cb0a774c3
|
4
|
+
data.tar.gz: cc05b289a65b53859ff5b2f30579cd2bbf8d7195f12a28b601ab9aa45cc45f19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bd173d87ad8ce311af2e4c35bd29a7a6376ce2805a0b308c7a8ac21509708a16965ef01134b3ac564a1541085858d851556fb488dd4a9bb17335603d0d786e5
|
7
|
+
data.tar.gz: 1a94c96c310f264110bd59dcf7eecf0063ac467de48a8de72c7c46c5779fe74d30109a11b00d142a576d925f03a32498ff0adf0faf873831a8b1314daed74158
|
@@ -1,16 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'openssl'
|
4
|
+
require 'securerandom'
|
4
5
|
|
5
6
|
module Kybus
|
6
7
|
module SSL
|
7
8
|
# Stores a X509 certificate.
|
8
9
|
class Certificate
|
9
|
-
attr_reader :cert, :key
|
10
|
+
attr_reader :cert, :key, :config
|
10
11
|
|
11
12
|
def initialize(config, inventory)
|
12
13
|
@config = config
|
13
14
|
@inventory = inventory
|
15
|
+
|
16
|
+
if File.file?(@config.key_path) && File.file?(@config.crt_path)
|
17
|
+
load_key!
|
18
|
+
else
|
19
|
+
create_key!
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def create_key!
|
24
|
+
puts @config.instance_variable_get(:@config)
|
14
25
|
@key = OpenSSL::PKey::RSA.new(@config['key_size'])
|
15
26
|
@cert = OpenSSL::X509::Certificate.new
|
16
27
|
@cert.public_key = @key.public_key
|
@@ -18,8 +29,15 @@ module Kybus
|
|
18
29
|
@extensions.subject_certificate = @cert
|
19
30
|
end
|
20
31
|
|
32
|
+
def load_key!
|
33
|
+
@key = OpenSSL::PKey::RSA.new(File.read(@config.key_path))
|
34
|
+
@cert = OpenSSL::X509::Certificate.new(File.read(@config.crt_path))
|
35
|
+
end
|
36
|
+
|
21
37
|
def create!
|
22
|
-
|
38
|
+
if File.file?(@config.key_path) && File.file?(@config.crt_path)
|
39
|
+
return puts "Certificate already exists #{@config.key_path} #{@cert.subject}"
|
40
|
+
end
|
23
41
|
|
24
42
|
@ca = @inventory.ca(@config['parent'])
|
25
43
|
configure_details!
|
@@ -43,8 +61,18 @@ module Kybus
|
|
43
61
|
end
|
44
62
|
|
45
63
|
def save!
|
64
|
+
puts "Saving certificate #{@cert.subject}"
|
46
65
|
File.write(@config.key_path, @key.to_s)
|
47
66
|
File.write(@config.crt_path, @cert.to_s)
|
67
|
+
export_to_pfx!
|
68
|
+
end
|
69
|
+
|
70
|
+
def export_to_pfx!
|
71
|
+
passphrase = SecureRandom.alphanumeric(15)
|
72
|
+
chain = [@cert] + @inventory.ca_cert_chain(@config['parent'])
|
73
|
+
pkcs12 = OpenSSL::PKCS12.create(passphrase, @config['email'] || @config['name'], @key, @cert, chain)
|
74
|
+
File.write(@config.pfx_path, pkcs12.to_der)
|
75
|
+
puts "PFX certificate saved with passphrase: #{passphrase}"
|
48
76
|
end
|
49
77
|
|
50
78
|
def ca_name
|
data/lib/kybus/ssl/cli/add_ca.rb
CHANGED
@@ -11,21 +11,19 @@ module Kybus
|
|
11
11
|
|
12
12
|
private
|
13
13
|
|
14
|
+
KEYS = %i[caname name expiration key_size].freeze
|
15
|
+
|
14
16
|
def update_yaml_file
|
15
|
-
new_ca =
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
critical: true
|
26
|
-
}
|
27
|
-
}
|
28
|
-
}
|
17
|
+
new_ca = opts_to_cert_config(KEYS,
|
18
|
+
parent: @opts[:ca] || 'root',
|
19
|
+
serial: next_serial,
|
20
|
+
name: @opts[:ca_name],
|
21
|
+
extensions: {
|
22
|
+
basicConstraints: {
|
23
|
+
details: 'CA:true, pathlen:0',
|
24
|
+
critical: true
|
25
|
+
}
|
26
|
+
})
|
29
27
|
|
30
28
|
@template['certificate_descriptions']['authorities']['certificates'] << new_ca
|
31
29
|
|
@@ -11,21 +11,15 @@ module Kybus
|
|
11
11
|
|
12
12
|
private
|
13
13
|
|
14
|
+
KEYS = %i[name expiration key_size team country city state email].freeze
|
15
|
+
|
14
16
|
def update_yaml_file
|
15
|
-
new_certificate = {
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
organization: @opts[:org],
|
22
|
-
team: @opts[:team],
|
23
|
-
country: @opts[:country],
|
24
|
-
city: @opts[:city],
|
25
|
-
state: @opts[:state],
|
26
|
-
email: @opts[:email],
|
27
|
-
revoked: false
|
28
|
-
}.compact
|
17
|
+
new_certificate = opts_to_cert_config(KEYS, {
|
18
|
+
parent: @opts[:ca],
|
19
|
+
serial: next_serial,
|
20
|
+
organization: @opts[:org],
|
21
|
+
revoked: false
|
22
|
+
})
|
29
23
|
|
30
24
|
@template['certificate_descriptions']['clients']['certificates'] << new_certificate
|
31
25
|
|
@@ -22,6 +22,12 @@ module Kybus
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
def opts_to_cert_config(keys, extra_args)
|
26
|
+
cert = {}
|
27
|
+
keys.each { |key| cert[key] = @opts[key] }
|
28
|
+
cert.merge(extra_args).compact
|
29
|
+
end
|
30
|
+
|
25
31
|
def load_template
|
26
32
|
@template = YAML.load_file(@opts[:pki_file])
|
27
33
|
end
|
data/lib/kybus/ssl/cli/build.rb
CHANGED
data/lib/kybus/ssl/cli/init.rb
CHANGED
@@ -5,6 +5,16 @@ require_relative 'base_command'
|
|
5
5
|
module Kybus
|
6
6
|
module SSL
|
7
7
|
module CLI
|
8
|
+
DEFAULT_EXPIRATION = 5
|
9
|
+
ROOT_CA_EXPIRATION = 20
|
10
|
+
SUB_CA_EXPIRATION = 10
|
11
|
+
ROOT_CA_SERIAL = 1
|
12
|
+
SERVERS_CA_SERIAL = 2
|
13
|
+
CLIENTS_CA_SERIAL = 3
|
14
|
+
ROOT_CA_KEY_SIZE = 4096
|
15
|
+
SUB_CA_KEY_SIZE = 2048
|
16
|
+
SERVERS_CA_EXPIRATION = 5
|
17
|
+
|
8
18
|
class Init < BaseCommand
|
9
19
|
def build_default_config
|
10
20
|
@template = {
|
@@ -20,78 +30,51 @@ module Kybus
|
|
20
30
|
|
21
31
|
def default_certificate_extensions
|
22
32
|
{
|
23
|
-
subjectKeyIdentifier:
|
24
|
-
|
25
|
-
|
26
|
-
},
|
27
|
-
authorityKeyIdentifier: {
|
28
|
-
details: 'keyid:always',
|
29
|
-
critical: false
|
30
|
-
},
|
31
|
-
basicConstraints: {
|
32
|
-
details: 'CA:false',
|
33
|
-
critical: false
|
34
|
-
}
|
33
|
+
subjectKeyIdentifier: extension_details('hash'),
|
34
|
+
authorityKeyIdentifier: extension_details('keyid:always'),
|
35
|
+
basicConstraints: extension_details('CA:false')
|
35
36
|
}
|
36
37
|
end
|
37
38
|
|
39
|
+
def extension_details(details, critical: false)
|
40
|
+
{ details:, critical: }
|
41
|
+
end
|
42
|
+
|
38
43
|
def certificate_defaults
|
39
44
|
{
|
40
|
-
saving_directory: @opts[:
|
45
|
+
saving_directory: @opts[:path],
|
41
46
|
country: @opts[:country],
|
42
47
|
state: @opts[:state],
|
43
48
|
city: @opts[:city],
|
44
49
|
organization: @opts[:organization],
|
45
50
|
team: @opts[:team],
|
46
51
|
key_size: @opts[:key_size],
|
47
|
-
expiration:
|
52
|
+
expiration: DEFAULT_EXPIRATION,
|
48
53
|
extensions: default_certificate_extensions
|
49
54
|
}
|
50
55
|
end
|
51
56
|
|
52
57
|
def root_ca
|
53
|
-
{
|
54
|
-
|
55
|
-
expiration: 20,
|
56
|
-
serial: 1,
|
57
|
-
key_size: 4096,
|
58
|
-
ca: 'root',
|
59
|
-
parent: 'root'
|
60
|
-
}
|
58
|
+
ca_config("#{@opts[:organization]} Root CA", ROOT_CA_EXPIRATION, ROOT_CA_SERIAL, ROOT_CA_KEY_SIZE, 'root',
|
59
|
+
'root')
|
61
60
|
end
|
62
61
|
|
63
62
|
def servers_ca
|
64
|
-
{
|
65
|
-
name: "#{@opts[:organization]} Servers CA",
|
66
|
-
parent: 'root',
|
67
|
-
expiration: 10,
|
68
|
-
serial: 2,
|
69
|
-
ca: 'servers',
|
70
|
-
key_size: 2048,
|
71
|
-
extensions: {
|
72
|
-
basicConstraints: {
|
73
|
-
details: 'CA:true, pathlen:0',
|
74
|
-
critical: true
|
75
|
-
}
|
76
|
-
}
|
77
|
-
}
|
63
|
+
sub_ca_config("#{@opts[:organization]} Servers CA", SERVERS_CA_EXPIRATION, SERVERS_CA_SERIAL, 'servers')
|
78
64
|
end
|
79
65
|
|
80
66
|
def clients_ca
|
81
|
-
{
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
}
|
93
|
-
}
|
94
|
-
}
|
67
|
+
sub_ca_config("#{@opts[:organization]} Clients CA", SUB_CA_EXPIRATION, CLIENTS_CA_SERIAL, 'clients')
|
68
|
+
end
|
69
|
+
|
70
|
+
def ca_config(name, expiration, serial, key_size, ca, parent, extensions: {}) # rubocop: disable Metrics/ParameterLists:
|
71
|
+
{ name:, expiration:, serial:, key_size:, ca:, parent:, extensions: }
|
72
|
+
end
|
73
|
+
|
74
|
+
def sub_ca_config(name, expiration, serial, ca)
|
75
|
+
ca_config(name, expiration, serial, SUB_CA_KEY_SIZE, ca, 'root', extensions: {
|
76
|
+
basicConstraints: extension_details('CA:true, pathlen:0', critical: true)
|
77
|
+
})
|
95
78
|
end
|
96
79
|
|
97
80
|
def default_authorities
|
@@ -99,90 +82,51 @@ module Kybus
|
|
99
82
|
defaults: {
|
100
83
|
parent: 'root',
|
101
84
|
extensions: {
|
102
|
-
basicConstraints:
|
103
|
-
|
104
|
-
critical: true
|
105
|
-
},
|
106
|
-
keyUsage: {
|
107
|
-
details: 'Digital Signature, keyCertSign, cRLSign',
|
108
|
-
critical: true
|
109
|
-
}
|
85
|
+
basicConstraints: extension_details('CA:true', critical: true),
|
86
|
+
keyUsage: extension_details('Digital Signature, keyCertSign, cRLSign', critical: true)
|
110
87
|
}
|
111
88
|
},
|
112
89
|
certificates: [root_ca, servers_ca, clients_ca]
|
113
90
|
}
|
114
91
|
end
|
115
92
|
|
116
|
-
def
|
93
|
+
def default_config(parent, extensions, extra_defaults = {})
|
117
94
|
{
|
118
95
|
defaults: {
|
119
|
-
parent
|
120
|
-
extensions:
|
121
|
-
|
122
|
-
details: 'SSL Server',
|
123
|
-
critical: false
|
124
|
-
},
|
125
|
-
'Netscape Comment': {
|
126
|
-
details: 'Server certificate',
|
127
|
-
critical: false
|
128
|
-
},
|
129
|
-
keyUsage: {
|
130
|
-
details: 'Digital Signature, Key Encipherment',
|
131
|
-
critical: true
|
132
|
-
},
|
133
|
-
extendedKeyUsage: {
|
134
|
-
details: 'TLS Web Server Authentication',
|
135
|
-
critical: false
|
136
|
-
},
|
137
|
-
authorityKeyIdentifier: {
|
138
|
-
details: 'keyid, issuer:always',
|
139
|
-
critical: false
|
140
|
-
},
|
141
|
-
subjectAltName: {
|
142
|
-
details: '$dns',
|
143
|
-
critical: false
|
144
|
-
}
|
145
|
-
}
|
146
|
-
},
|
96
|
+
parent:,
|
97
|
+
extensions:
|
98
|
+
}.merge(extra_defaults),
|
147
99
|
certificates: []
|
148
100
|
}
|
149
101
|
end
|
150
102
|
|
103
|
+
def default_servers_config
|
104
|
+
extensions = {
|
105
|
+
'Netscape Cert Type': extension_details('SSL Server'),
|
106
|
+
'Netscape Comment': extension_details('Server certificate'),
|
107
|
+
keyUsage: extension_details('Digital Signature, Key Encipherment', critical: true),
|
108
|
+
extendedKeyUsage: extension_details('TLS Web Server Authentication'),
|
109
|
+
authorityKeyIdentifier: extension_details('keyid, issuer:always'),
|
110
|
+
subjectAltName: extension_details('$dns')
|
111
|
+
}
|
112
|
+
default_config('servers', extensions)
|
113
|
+
end
|
114
|
+
|
151
115
|
def default_clients_config
|
152
|
-
{
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
critical: false
|
159
|
-
},
|
160
|
-
'Netscape Comment': {
|
161
|
-
details: 'Client certificate',
|
162
|
-
critical: false
|
163
|
-
},
|
164
|
-
keyUsage: {
|
165
|
-
details: 'Digital Signature, Non Repudiation, Key Encipherment',
|
166
|
-
critical: true
|
167
|
-
},
|
168
|
-
extendedKeyUsage: {
|
169
|
-
details: 'TLS Web Client Authentication, E-mail Protection',
|
170
|
-
critical: false
|
171
|
-
},
|
172
|
-
subjectAltName: {
|
173
|
-
details: '$email',
|
174
|
-
critical: false
|
175
|
-
}
|
176
|
-
},
|
177
|
-
team: @opts[:team]
|
178
|
-
},
|
179
|
-
certificates: []
|
116
|
+
extensions = {
|
117
|
+
'Netscape Cert Type': extension_details('SSL Client, S/MIME'),
|
118
|
+
'Netscape Comment': extension_details('Client certificate'),
|
119
|
+
keyUsage: extension_details('Digital Signature, Non Repudiation, Key Encipherment', critical: true),
|
120
|
+
extendedKeyUsage: extension_details('TLS Web Client Authentication, E-mail Protection'),
|
121
|
+
subjectAltName: extension_details('$email')
|
180
122
|
}
|
123
|
+
default_config('clients', extensions, team: @opts[:team])
|
181
124
|
end
|
182
125
|
|
183
126
|
def run
|
184
127
|
abort 'File already exists. Use --force to overwrite.' if pki_file_exist? && !@opts[:force]
|
185
128
|
build_default_config
|
129
|
+
FileUtils.mkdir_p(@opts[:path])
|
186
130
|
save_template
|
187
131
|
end
|
188
132
|
end
|
data/lib/kybus/ssl/cli.rb
CHANGED
@@ -11,8 +11,6 @@ module Kybus
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def saving_directory(type)
|
14
|
-
path = @config['saving_directory']
|
15
|
-
serial = @config['serial']
|
16
14
|
"#{path}/#{serial}.#{type}.pem"
|
17
15
|
end
|
18
16
|
|
@@ -24,6 +22,10 @@ module Kybus
|
|
24
22
|
saving_directory('key')
|
25
23
|
end
|
26
24
|
|
25
|
+
def pfx_path
|
26
|
+
"#{path}/#{serial}-#{@config['email'] || @config['name']}.pfx"
|
27
|
+
end
|
28
|
+
|
27
29
|
def subject_string
|
28
30
|
"/C=#{@config['country']}/ST=#{@config['state']}" \
|
29
31
|
"/L=#{@config['city']}/O=#{@config['organization']}" \
|
@@ -61,6 +63,15 @@ module Kybus
|
|
61
63
|
def [](key)
|
62
64
|
@config[key]
|
63
65
|
end
|
66
|
+
private
|
67
|
+
|
68
|
+
def path
|
69
|
+
@config['saving_directory']
|
70
|
+
end
|
71
|
+
|
72
|
+
def serial
|
73
|
+
@config['serial']
|
74
|
+
end
|
64
75
|
end
|
65
76
|
end
|
66
77
|
end
|
data/lib/kybus/ssl/inventory.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require_relative 'configuration'
|
4
4
|
require_relative 'certificate'
|
5
5
|
require_relative 'revocation_list'
|
6
|
+
require 'yaml'
|
6
7
|
|
7
8
|
require 'fileutils'
|
8
9
|
|
@@ -23,17 +24,31 @@ module Kybus
|
|
23
24
|
@servers = SubInventory.new(servers, self)
|
24
25
|
end
|
25
26
|
|
27
|
+
def self.load_inventory(path)
|
28
|
+
inventory = YAML.load_file(path)
|
29
|
+
data = inventory['certificate_descriptions']
|
30
|
+
new(data['defaults'], data['authorities'], data['clients'], data['servers'])
|
31
|
+
end
|
32
|
+
|
26
33
|
def create_certificates!
|
27
34
|
validate_inventories!
|
28
35
|
create_directory!
|
29
36
|
[@authorities, @clients, @servers].each(&:create_certificates!)
|
30
37
|
end
|
31
38
|
|
39
|
+
def ca_cert_chain(parent)
|
40
|
+
@authorities.ca_cert_chain(parent)
|
41
|
+
end
|
42
|
+
|
32
43
|
# TODO: Implement validation of inventories
|
33
44
|
def validate_inventories!
|
34
45
|
true
|
35
46
|
end
|
36
47
|
|
48
|
+
def update_crl
|
49
|
+
@authorities.update_crl
|
50
|
+
end
|
51
|
+
|
37
52
|
def create_directory!
|
38
53
|
FileUtils.mkdir_p(@defaults['saving_directory'])
|
39
54
|
end
|
@@ -61,6 +76,21 @@ module Kybus
|
|
61
76
|
end
|
62
77
|
end
|
63
78
|
|
79
|
+
def ca_cert_chain(name)
|
80
|
+
chain = []
|
81
|
+
cert = ca(name)
|
82
|
+
|
83
|
+
while cert && cert.ca_name != 'root'
|
84
|
+
puts cert.ca_name
|
85
|
+
chain << cert.cert
|
86
|
+
cert = @certificates.find { |c| c.ca_name == cert.config['parent'] }
|
87
|
+
end
|
88
|
+
chain
|
89
|
+
end
|
90
|
+
|
91
|
+
def update_crl
|
92
|
+
end
|
93
|
+
|
64
94
|
def create_certificates!
|
65
95
|
@certificates.each(&:create!)
|
66
96
|
end
|
data/lib/kybus/ssl/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kybus-ssl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gilberto Vargas
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: optimist
|
@@ -24,99 +24,13 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: minitest
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '5.11'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '5.11'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: pry
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0.12'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0.12'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rake
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '12.3'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '12.3'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rdoc
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '6.1'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '6.1'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: simplecov
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0.16'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0.16'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: webmock
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '3.5'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '3.5'
|
111
27
|
description: Package for creating self signed certificates for development purpose
|
112
28
|
email:
|
113
|
-
-
|
114
|
-
executables:
|
115
|
-
- kybssl
|
29
|
+
- tachomexgems@gmail.com
|
30
|
+
executables: []
|
116
31
|
extensions: []
|
117
32
|
extra_rdoc_files: []
|
118
33
|
files:
|
119
|
-
- bin/kybssl
|
120
34
|
- lib/kybus/ssl.rb
|
121
35
|
- lib/kybus/ssl/certificate.rb
|
122
36
|
- lib/kybus/ssl/cli.rb
|
@@ -125,17 +39,17 @@ files:
|
|
125
39
|
- lib/kybus/ssl/cli/base_command.rb
|
126
40
|
- lib/kybus/ssl/cli/build.rb
|
127
41
|
- lib/kybus/ssl/cli/init.rb
|
128
|
-
- lib/kybus/ssl/cli/
|
42
|
+
- lib/kybus/ssl/cli/update_crl.rb
|
129
43
|
- lib/kybus/ssl/configuration.rb
|
130
44
|
- lib/kybus/ssl/inventory.rb
|
131
45
|
- lib/kybus/ssl/revocation_list.rb
|
132
46
|
- lib/kybus/ssl/version.rb
|
133
|
-
homepage: https://github.com/
|
47
|
+
homepage: https://github.com/tachomex/kybus
|
134
48
|
licenses:
|
135
49
|
- MIT
|
136
50
|
metadata:
|
137
51
|
rubygems_mfa_required: 'true'
|
138
|
-
post_install_message:
|
52
|
+
post_install_message:
|
139
53
|
rdoc_options: []
|
140
54
|
require_paths:
|
141
55
|
- lib
|
@@ -150,8 +64,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
64
|
- !ruby/object:Gem::Version
|
151
65
|
version: '0'
|
152
66
|
requirements: []
|
153
|
-
rubygems_version: 3.5.
|
154
|
-
signing_key:
|
67
|
+
rubygems_version: 3.5.9
|
68
|
+
signing_key:
|
155
69
|
specification_version: 4
|
156
70
|
summary: Kybus SSL tools
|
157
71
|
test_files: []
|
data/bin/kybssl
DELETED
@@ -1,90 +0,0 @@
|
|
1
|
-
require 'optimist'
|
2
|
-
require 'yaml'
|
3
|
-
require './lib/kybus/ssl/cli'
|
4
|
-
|
5
|
-
def run_init(opts)
|
6
|
-
Kybus::SSL::CLI::Init.new(opts).run
|
7
|
-
end
|
8
|
-
|
9
|
-
def run_add_ca(opts)
|
10
|
-
Kybus::SSL::CLI::AddCA.new(opts).run
|
11
|
-
end
|
12
|
-
|
13
|
-
def run_add_certificate(opts)
|
14
|
-
Kybus::SSL::CLI::AddCertificate.new(opts).run
|
15
|
-
end
|
16
|
-
|
17
|
-
def run_revoke_certificate(opts); end
|
18
|
-
|
19
|
-
def run_build(opts); end
|
20
|
-
|
21
|
-
# Define expected commands and options
|
22
|
-
commands = %i[init add_ca add_certificate revoke_certificate build]
|
23
|
-
cmd = ARGV.shift&.to_sym || :help
|
24
|
-
abort "Invalid command. Valid commands are: #{commands.join(', ')}" unless commands.include?(cmd)
|
25
|
-
|
26
|
-
def global_params(context, cmd)
|
27
|
-
context.instance_eval do
|
28
|
-
opt :pki_file, 'PKI File', type: :string, required: true
|
29
|
-
opt :team, 'Organization Unit name', type: :string, required: cmd == :init
|
30
|
-
opt :country, 'Organization Unit name', type: :string, required: cmd == :init
|
31
|
-
opt :state, 'Organization Unit name', type: :string, required: cmd == :init
|
32
|
-
opt :city, 'Organization Unit name', type: :string, required: cmd == :init
|
33
|
-
opt :organization, 'Organization Unit name', type: :string, required: cmd == :init
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
opts = case cmd
|
38
|
-
when :init
|
39
|
-
Optimist.options do
|
40
|
-
banner 'Usage: kybssl init [options]'
|
41
|
-
opt :outputdir, 'Output Directory', type: :string, default: 'pki'
|
42
|
-
opt :force, 'Overwrite file if it already exists', type: :bool, default: false
|
43
|
-
global_params(self, cmd)
|
44
|
-
end
|
45
|
-
when :add_ca
|
46
|
-
Optimist.options do
|
47
|
-
banner 'Usage: kybssl add-ca [options]'
|
48
|
-
opt :caname, 'CA Name', type: :string, required: true
|
49
|
-
opt :name, 'Common Name', type: :string, required: true
|
50
|
-
opt :expiration, 'Validity Years', type: :integer, default: 10
|
51
|
-
opt :keysize, 'Key Size', type: :integer, default: 2048
|
52
|
-
opt :parent, 'Parent CA', type: :string, default: 'root'
|
53
|
-
global_params(self, cmd)
|
54
|
-
end
|
55
|
-
when :add_certificate
|
56
|
-
Optimist.options do
|
57
|
-
banner 'Usage: kybssl add-certificate [options]'
|
58
|
-
opt :name, 'Common Name', type: :string, required: true
|
59
|
-
opt :email, 'User Email', type: :string, require: true
|
60
|
-
opt :dns, 'Server DNS', type: :string
|
61
|
-
opt :ca, 'CA Name', type: :string, required: true
|
62
|
-
opt :expiration, 'Validity Years', type: :integer, default: 5
|
63
|
-
opt :type, 'Type of certificate client|server', type: :string, default: 'client'
|
64
|
-
global_params(self, cmd)
|
65
|
-
end
|
66
|
-
when :revoke_certificate
|
67
|
-
Optimist.options do
|
68
|
-
banner 'Usage: kybssl revoke-certificate [options]'
|
69
|
-
opt :serial, 'Certificate Serial', type: :string, required: true
|
70
|
-
global_params(self, cmd)
|
71
|
-
end
|
72
|
-
when :build
|
73
|
-
Optimist.options do
|
74
|
-
banner 'Usage: kybssl build [options]'
|
75
|
-
global_params(self, cmd)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
case cmd
|
80
|
-
when :init
|
81
|
-
run_init(opts)
|
82
|
-
when :add_ca
|
83
|
-
run_add_ca(opts)
|
84
|
-
when :add_certificate
|
85
|
-
run_add_certificate(opts)
|
86
|
-
when :revoke_certificate
|
87
|
-
run_revoke_certificate(opts)
|
88
|
-
when :build
|
89
|
-
run_build(opts)
|
90
|
-
end
|
File without changes
|