certie 0.0.2 → 0.0.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/lib/certie.rb +13 -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: abc0197ecfa93b01239a134fdb325a023ec592af745a9e1059c34fc8b73f2590
|
4
|
+
data.tar.gz: 6d343288fc2d0f87d48f6e9e5d825fada99ec9d991e92bd9fbbe171de8fe6ff7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e5d2109226252edd3bf798ec4979aaaefac17766aa35c515222fca8788a5591d4c3cf33055997f3f01e511d4b808f30dbf1f1b1ed1e20a7513dec9e7d19cdfd
|
7
|
+
data.tar.gz: 4f01c0f776deaf0e42197b256dd2f34c06bd5c6bfa1b4df88708530428da932d9774c4efc1e5d32011ca17cb8355875bc9fa8a10ecc2277b28f4f982d4d57ac9
|
data/lib/certie.rb
CHANGED
@@ -4,6 +4,15 @@ require 'openssl'
|
|
4
4
|
class CertificateWrapper
|
5
5
|
@@subject_prefix = '/C=AE/ST=Dubai/L=Dubai/O=KNR/OU=Software'
|
6
6
|
|
7
|
+
def self.load_subject_prefix
|
8
|
+
filename = "#{Dir.home}/.certie_subjprefix"
|
9
|
+
if File.exists?(filename)
|
10
|
+
@@subject_prefix = File.read(filename).chomp!
|
11
|
+
else
|
12
|
+
File.write(filename, @@subject_prefix)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
7
16
|
def self.get_counter_next
|
8
17
|
serial = 0
|
9
18
|
if File.exists?('serial.txt')
|
@@ -50,7 +59,6 @@ class CertificateWrapper
|
|
50
59
|
|
51
60
|
ef = OpenSSL::X509::ExtensionFactory.new
|
52
61
|
|
53
|
-
|
54
62
|
if cn == "ca"
|
55
63
|
cert.issuer = OpenSSL::X509::Name.parse subject
|
56
64
|
ef.subject_certificate = cert
|
@@ -82,15 +90,19 @@ class CertificateWrapper
|
|
82
90
|
end
|
83
91
|
end
|
84
92
|
|
93
|
+
# TODO: Find an alternative to invoking OpenSSL and cat
|
85
94
|
`openssl pkcs8 -topk8 -inform pem -in "#{cn}.rsa" -out "#{cn}.key" -nocrypt`
|
86
95
|
`cat "#{cn}.cert" "#{cn}.key" > "#{cn}.pem"`
|
87
96
|
end
|
88
97
|
|
89
98
|
|
90
99
|
def self.build(cn)
|
100
|
+
load_subject_prefix
|
101
|
+
|
91
102
|
doWeHaveARootCertificate = File.exists? 'ca.cert'
|
92
103
|
doWeHaveARootKey = File.exists? 'ca.rsa'
|
93
104
|
|
105
|
+
# TODO: Handle the case where we have only one and not the other (cert and key)
|
94
106
|
if not (doWeHaveARootCertificate and doWeHaveARootKey)
|
95
107
|
create_certificate
|
96
108
|
end
|