certie 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/certie.rb +13 -1
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d6e1cb8a0e33e9293d80d691f0e8823c67810b388212569e45afcbcd926bfbc9
4
- data.tar.gz: 3efbdc54c10c9f838d62a257d4427813d24f3f6546531e97a88f3c6a52341d20
3
+ metadata.gz: abc0197ecfa93b01239a134fdb325a023ec592af745a9e1059c34fc8b73f2590
4
+ data.tar.gz: 6d343288fc2d0f87d48f6e9e5d825fada99ec9d991e92bd9fbbe171de8fe6ff7
5
5
  SHA512:
6
- metadata.gz: 2463d49a316393ad773e4101bf8307d9db69783f4efecaacb84568bbc0a2a993c527356cc95991edb2c3f9cd56d56aa2fe0f4608745da6c6a5d0ac0697cf6f32
7
- data.tar.gz: 223456217cfc468be901fe28fb161e09ed923cbfaf76905b3681e5d64c0e7bf8bd30e5753cf57eeeec344ea2fe99ddfb731ae60c4158093c4fcaeb8a8b31e0f8
6
+ metadata.gz: 7e5d2109226252edd3bf798ec4979aaaefac17766aa35c515222fca8788a5591d4c3cf33055997f3f01e511d4b808f30dbf1f1b1ed1e20a7513dec9e7d19cdfd
7
+ data.tar.gz: 4f01c0f776deaf0e42197b256dd2f34c06bd5c6bfa1b4df88708530428da932d9774c4efc1e5d32011ca17cb8355875bc9fa8a10ecc2277b28f4f982d4d57ac9
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: certie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katkam Nitin Reddy