seguridad 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/bin/seguridad +1 -1
- data/lib/seguridad.rb +14 -13
- 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: bfdb15cee8cd819c1e601263e7a7eaf2b6900e39
|
|
4
|
+
data.tar.gz: 9a602473c8e2f214bb6739d39c1d0d5d641cf6e3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 40b403088580c48ec816ec5c75f1891e728889c04c90681efa3bcf086a4629d0d8d24d8e9b60b3319401dff78c2db6c823c059415b95ad1f09905588c79bee04
|
|
7
|
+
data.tar.gz: f491ed6873a2dc80808c172df92ca778b1ebbef8a5640b45efe05755c622db497cad4628eebb88e65fc62e94c5cfb74fca4380c9715639228fd41748af6806b9
|
data/bin/seguridad
CHANGED
data/lib/seguridad.rb
CHANGED
|
@@ -4,32 +4,33 @@ require 'OpenSSL'
|
|
|
4
4
|
require 'socket'
|
|
5
5
|
|
|
6
6
|
class OpenSSL::X509::Certificate
|
|
7
|
-
|
|
7
|
+
attr_accessor :domain
|
|
8
|
+
|
|
8
9
|
def to_s
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
[
|
|
11
|
+
domain,
|
|
12
|
+
"\tName: #{subject.to_s.match(/\/CN=[^\s]*/).to_s.split("=")[1]}",
|
|
13
|
+
"\tIssuer: #{issuer}",
|
|
14
|
+
"\tNot Before: #{not_before}",
|
|
15
|
+
"\tNot After: #{not_after}",
|
|
16
|
+
"\tVersion: #{version}"
|
|
17
|
+
].join("\n")
|
|
16
18
|
end
|
|
17
19
|
end
|
|
18
20
|
|
|
21
|
+
# Return a monkey-patched X509 certificate for the given domain
|
|
19
22
|
def get_cert_info(domain)
|
|
20
|
-
puts domain
|
|
21
23
|
port = 443
|
|
22
24
|
tokens = domain.split(':')
|
|
23
25
|
if tokens.length > 1
|
|
24
26
|
domain = tokens[0]
|
|
25
27
|
port = tokens[-1].to_i
|
|
26
28
|
end
|
|
27
|
-
ctx = OpenSSL::SSL::SSLContext.new
|
|
28
29
|
socket = TCPSocket.new(domain, port)
|
|
29
|
-
|
|
30
|
+
ctx = OpenSSL::SSL::SSLContext.new
|
|
30
31
|
tls = OpenSSL::SSL::SSLSocket.new(socket, ctx)
|
|
31
32
|
tls.connect
|
|
32
33
|
cert = OpenSSL::X509::Certificate.new tls.peer_cert
|
|
33
|
-
cert.
|
|
34
|
-
|
|
34
|
+
cert.domain = domain
|
|
35
|
+
cert
|
|
35
36
|
end
|