simbiotes 0.1.13 → 0.1.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/simbiotes/server.rb +18 -9
- data/lib/simbiotes/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e232c7fdf51c37df9dfb0d07f144eaabf521032b
|
4
|
+
data.tar.gz: 96c89e62feb57de8aa9bc3352a57bfe64ff2203e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76530d0667b5547448545667d811abc508bcda776e16eee2b7e1e68cd1c72f6035ff9300c18837c5984058875c6226efccaf4950c88a47dae6379ab6a2820d8c
|
7
|
+
data.tar.gz: 4108aed32cd6d41a9513b2ac5d2d7a2b4da1263a5ac25ade88ee0ad975c3ab6993015475a24c60f2a2b504592b8ad897d9a711ca2300b2a19496f6ab7f1827c7
|
data/lib/simbiotes/server.rb
CHANGED
@@ -15,12 +15,12 @@ module Simbiotes
|
|
15
15
|
if rgs == nil
|
16
16
|
server_details = Server.lookup
|
17
17
|
if server_details["status"] == "ok"
|
18
|
-
rgs = server_details["
|
18
|
+
rgs = server_details["IP"]
|
19
19
|
c = SimbiotesSetting.new
|
20
20
|
c.key = "server"
|
21
21
|
c.value = rgs
|
22
22
|
c.save
|
23
|
-
rgs_port = server_details["
|
23
|
+
rgs_port = server_details["port"]
|
24
24
|
c = SimbiotesSetting.new
|
25
25
|
c.key = "port"
|
26
26
|
c.value = rgs_port
|
@@ -35,12 +35,18 @@ module Simbiotes
|
|
35
35
|
context.key = Server.key
|
36
36
|
context.cert = Server.cert
|
37
37
|
if Simbiotes.configuration.verify_peer == true
|
38
|
-
|
38
|
+
ca_tempfile = Tempfile.new
|
39
|
+
ca_tempfile.write Server.ca_cert.to_pem
|
40
|
+
ca_tempfile.rewind
|
41
|
+
context.ca_file = ca_tempfile.path
|
39
42
|
context.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
40
43
|
end
|
41
44
|
server = OpenSSL::SSL::SSLSocket.new socket, context
|
42
45
|
server.sync_close = true
|
43
46
|
server.connect
|
47
|
+
if Simbiotes.configuration.verify_peer == true
|
48
|
+
ca_tempfile.close(true)
|
49
|
+
end
|
44
50
|
else
|
45
51
|
server = TCPSocket.open(rgs, rgs_port)
|
46
52
|
end
|
@@ -114,7 +120,10 @@ module Simbiotes
|
|
114
120
|
context.key = Server.key
|
115
121
|
context.cert = Server.cert
|
116
122
|
if Simbiotes.configuration.verify_peer == true
|
117
|
-
|
123
|
+
ca_tempfile = Tempfile.new
|
124
|
+
ca_tempfile.write Server.ca_cert.to_pem
|
125
|
+
ca_tempfile.rewind
|
126
|
+
context.ca_file = ca_tempfile.path
|
118
127
|
context.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
119
128
|
end
|
120
129
|
server = OpenSSL::SSL::SSLSocket.new socket, context
|
@@ -127,6 +136,9 @@ module Simbiotes
|
|
127
136
|
msg = server.gets
|
128
137
|
hash = JSON.parse(msg)
|
129
138
|
server.close
|
139
|
+
if Simbiotes.configuration.verify_peer == true
|
140
|
+
ca_tempfile.close(true)
|
141
|
+
end
|
130
142
|
return hash
|
131
143
|
end
|
132
144
|
|
@@ -145,11 +157,8 @@ module Simbiotes
|
|
145
157
|
def self.cert
|
146
158
|
cert = SimbiotesSetting.find_by(key: "cert")
|
147
159
|
if cert == nil
|
148
|
-
key =
|
149
|
-
|
150
|
-
key = OpenSSL::PKey::RSA.new key, pass_phrase
|
151
|
-
public_key = SimbiotesSetting.find_by(key: "public_key").value
|
152
|
-
public_key = OpenSSL::PKey::RSA.new public_key
|
160
|
+
key = Server.key
|
161
|
+
public_key = key.public_key
|
153
162
|
cert = Server.generate_cert(key, public_key)
|
154
163
|
c = SimbiotesSetting.new
|
155
164
|
c.key = "cert"
|
data/lib/simbiotes/version.rb
CHANGED