certie 0.0.2 → 0.0.6
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/certie.rb +31 -4
- metadata +13 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2db9bf5d411b177f146378f28e2509444c5944dbf27fa1dbc8062cd5b301cfb
|
4
|
+
data.tar.gz: 4fe3a8adc909773c1e7507bb4fc6101a6995b3d552f16e4d3edeed75cbea65fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4182a42d5b81261762c2b8fb03e9d9f5a8739f9b78d12836dda196eefc7c835283e1d3ea70b43183d347c8d897ba52d853ae6801d5c499c655069cc835064910
|
7
|
+
data.tar.gz: 4d1cfc800b64721cbb1c080aa142e2647d7301ae6964d8641d9ababc4250607b39d150ac48529ab7680ec5e40115da19bb821d89dfd2ac027364060b4094e394
|
data/lib/certie.rb
CHANGED
@@ -1,9 +1,26 @@
|
|
1
|
-
|
2
1
|
require 'openssl'
|
3
2
|
|
4
3
|
class CertificateWrapper
|
5
4
|
@@subject_prefix = '/C=AE/ST=Dubai/L=Dubai/O=KNR/OU=Software'
|
6
5
|
|
6
|
+
def self.load_subject_prefix
|
7
|
+
filename = "#{Dir.home}/.certie_subjprefix"
|
8
|
+
if File.exists?(filename)
|
9
|
+
@@subject_prefix = File.read(filename).chomp
|
10
|
+
else
|
11
|
+
File.write(filename, @@subject_prefix)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.file_cat(output_file, input_array)
|
16
|
+
File.open output_file, 'w' do |outfile|
|
17
|
+
input_array.each do |iter_infile|
|
18
|
+
outfile.write(File.read(iter_infile))
|
19
|
+
outfile.write "\n"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
7
24
|
def self.get_counter_next
|
8
25
|
serial = 0
|
9
26
|
if File.exists?('serial.txt')
|
@@ -50,7 +67,6 @@ class CertificateWrapper
|
|
50
67
|
|
51
68
|
ef = OpenSSL::X509::ExtensionFactory.new
|
52
69
|
|
53
|
-
|
54
70
|
if cn == "ca"
|
55
71
|
cert.issuer = OpenSSL::X509::Name.parse subject
|
56
72
|
ef.subject_certificate = cert
|
@@ -74,6 +90,7 @@ class CertificateWrapper
|
|
74
90
|
ef.issuer_certificate = rootCert
|
75
91
|
# cert.add_extension ef.create_extension('keyUsage', 'digitalSignature', true) # TODO: check if we can set webServer and webClient
|
76
92
|
cert.add_extension ef.create_extension('subjectKeyIdentifier', 'hash', false )
|
93
|
+
cert.add_extension ef.create_extension('subjectAltName', 'DNS:' + cn, false) #This can be CSV of multiple DNS: and IP: entries
|
77
94
|
|
78
95
|
cert.sign rootKey, OpenSSL::Digest.new('SHA256')
|
79
96
|
|
@@ -82,15 +99,25 @@ class CertificateWrapper
|
|
82
99
|
end
|
83
100
|
end
|
84
101
|
|
85
|
-
|
86
|
-
`
|
102
|
+
# An alternative to invoking OpenSSL and cat - OpenSSL v2.2.0 has private_to_pem in OpenSSL::PKey
|
103
|
+
# `openssl pkcs8 -topk8 -inform pem -in "#{cn}.rsa" -out "#{cn}.key" -nocrypt`
|
104
|
+
File.open "#{cn}.key", 'wb' do |myfile|
|
105
|
+
myfile.print(key.private_to_pem)
|
106
|
+
end
|
107
|
+
|
108
|
+
# Replaced system call cat with file_cat method
|
109
|
+
# `cat "#{cn}.cert" "#{cn}.key" > "#{cn}.pem"`
|
110
|
+
file_cat "#{cn}.pem", ["#{cn}.cert", "#{cn}.key"]
|
87
111
|
end
|
88
112
|
|
89
113
|
|
90
114
|
def self.build(cn)
|
115
|
+
load_subject_prefix
|
116
|
+
|
91
117
|
doWeHaveARootCertificate = File.exists? 'ca.cert'
|
92
118
|
doWeHaveARootKey = File.exists? 'ca.rsa'
|
93
119
|
|
120
|
+
# TODO: Handle the case where we have only one and not the other (cert and key)
|
94
121
|
if not (doWeHaveARootCertificate and doWeHaveARootKey)
|
95
122
|
create_certificate
|
96
123
|
end
|
metadata
CHANGED
@@ -1,31 +1,31 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: certie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Katkam Nitin Reddy
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: openssl
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.2.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
27
|
-
description:
|
28
|
-
email:
|
26
|
+
version: 2.2.0
|
27
|
+
description:
|
28
|
+
email:
|
29
29
|
executables:
|
30
30
|
- certie
|
31
31
|
extensions: []
|
@@ -33,10 +33,10 @@ extra_rdoc_files: []
|
|
33
33
|
files:
|
34
34
|
- bin/certie
|
35
35
|
- lib/certie.rb
|
36
|
-
homepage:
|
36
|
+
homepage:
|
37
37
|
licenses: []
|
38
38
|
metadata: {}
|
39
|
-
post_install_message:
|
39
|
+
post_install_message:
|
40
40
|
rdoc_options: []
|
41
41
|
require_paths:
|
42
42
|
- lib
|
@@ -51,8 +51,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '0'
|
53
53
|
requirements: []
|
54
|
-
rubygems_version: 3.
|
55
|
-
signing_key:
|
54
|
+
rubygems_version: 3.2.22
|
55
|
+
signing_key:
|
56
56
|
specification_version: 4
|
57
57
|
summary: A utility for generating certificates
|
58
58
|
test_files: []
|