ssl_gate 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6249ae8b79002d80de3d5710270887c8894834db
4
- data.tar.gz: f3c9e97ddc513d3ebc72306f8c1ab5cca7c32ec6
3
+ metadata.gz: 92b578960bbd25e7058bad491b83f7bb026767dc
4
+ data.tar.gz: ac7839bd28394bc60cc02a9151bf5cc04c14b02e
5
5
  SHA512:
6
- metadata.gz: 469ccb88950f8402c3d01576e19a02ab7ba720a47177e15c4337a97239c0d8001f407103bce7d8c6c4a819fd03237e2418219659dde972c2e1db514baab7ba8a
7
- data.tar.gz: 9d6feea10dc30a8985f36293e314e7a44de9a147cc4c33774c17b1beace980bc36e65186d13c26efe5e68d196d3c2826067d972f62199560da49c1319859906f
6
+ metadata.gz: 509edb533cbc2136467d5da93879ddebec7c65b43aff437813c2d7d433abe2650fcf1501b8c66e13ad3c1c90c3780a13770d45ca3369791ae107f000bbe40efa
7
+ data.tar.gz: 5e72450a05d0da8abfba09ce1f36d3f1ffd67d280ca2459e4bab9eeebd5a39cce3d5b83a2a3022458f788d03fc897153eb3f5a483c1e86d902112308b290f260
@@ -24,10 +24,9 @@ module SSLGate
24
24
 
25
25
  def self.factory(config)
26
26
  config.each do |key, conf|
27
- case key.to_s
28
- when 'http' then HTTPServerAll.start conf
29
- when 'tcp' then RawServerAll.start conf
30
- else STDERR.puts "Unknown gate type: #{key}"
27
+ case conf[:target]
28
+ when /http/ then HTTPServerAll.start conf
29
+ else RawServerAll.start conf
31
30
  end
32
31
  end
33
32
  end
@@ -0,0 +1,21 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIDizCCAnOgAwIBAgIJAKR1jigaAG1WMA0GCSqGSIb3DQEBCwUAMFwxCzAJBgNV
3
+ BAYTAlVTMQ8wDQYDVQQIDAZEZW5pYWwxFDASBgNVBAcMC1NwcmluZ2ZpZWxkMQww
4
+ CgYDV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dsFArS+5Oj7VdNdzyEuZcT1BD0O0c/UoJeLDjcpGFZ7oUN9LDA
16
+ 0EYs98ttyK290YUXTQPkmlDRCwKBgQDe38rXmZORMXpTlg3wvGXBcDh40pbPhU3P
17
+ 352DQhojgdu0dLki49X1HanBKEOVCQcUWJ2GuyR1BLJtXYu+D13UR+7qm7rb6B8P
18
+ lLs+QobtLnbLoNt/YhsTV5rbU35JGaQzzx2tYYhNkDArnlxdc+GqE5mlGcV/PZOU
19
+ GEIWlajOOQKBgQC8NpaytPL1Hd0el7lUN3AIqpO10M+ulPHBpsAhLf/+CsBH1fbU
20
+ I1sg4k70MV8JE6DBbpzaS7jIMgMZqPslUSzVF+jyTW3Cf2OJNF5AQVlnkRPtHU2n
21
+ biNlsxHK1vkOWWeqn4KIJLWnAYRnluWxRGyjfWKxa/LyxTUnk6rjIrXLSQKBgQCn
22
+ d0kXT5KOWrsr62h2J1neS9BjGPmw3N1nAQN+CUFSxNStd7dU/BVcpPlU5khByBLF
23
+ uwBCqIPwWaMogk3qdelvBM4FAxcY/gW4020OjzaLKYqh3zCPOsxVcFIv00Dk9Jtp
24
+ QotuKAcfIOTRIaENp3E9NpUQdZjszvwBH2kpRzMcIQKBgEaWugJeyf681lJ0NNdN
25
+ 0RkbdZnpGyjX4FbtIyt/5boWDX/OLKnlQOoaGD8g7UCqpgIztqMXG4+Oliqgs9Vn
26
+ G8n6cE1ALkDfKXJLg98GUGAp8BGGwU0Gg+0bYtLmQSccu/VSk0P1NEcuTM7SCHTp
27
+ dHMRwScLLEGIhugNEokMlgiB
28
+ -----END PRIVATE KEY-----
@@ -0,0 +1,18 @@
1
+ #!/bin/bash
2
+ cd "$(dirname "$0")"
3
+
4
+ #Generage CA (self-signed)
5
+ openssl req -x509 -nodes -days 5000 -newkey rsa:2048 -keyout ca.key -out ca.crt -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com"
6
+
7
+
8
+ #Debug dump
9
+ openssl x509 -in ca.crt -noout -text >ca.txt
10
+ openssl x509 -noout -fingerprint -in ca.crt >> ca.txt
11
+
12
+ openssl verify -verbose -CAfile ca.crt ca.crt
13
+
14
+
15
+ #Calculate SKI (Subject Key Identifier)
16
+ openssl x509 -noout -in ca.crt -pubkey | openssl asn1parse -strparse 19 -out ca.pub.tmp 1>/dev/null
17
+ openssl dgst -c -sha1 ca.pub.tmp
18
+ rm *.tmp
@@ -0,0 +1,17 @@
1
+ #!/bin/bash
2
+ cd "$(dirname "$0")"
3
+ #ALTNAME="DNS:<host1>,DNS:<host2>"
4
+
5
+ #Generate certificate
6
+ openssl genrsa -out server.key 2048
7
+
8
+
9
+ openssl req -new -key server.key -out server.csr -subj "/O=Group/OU=Youtest/CN=localhost"
10
+
11
+ openssl x509 -req -extfile v3.ext -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt -days 3650\
12
+ -extfile <(cat ./v3.ext <(printf "\nsubjectAltName=IP:127.0.0.1,DNS:127.0.0.1"))
13
+
14
+ #Debug dump
15
+ openssl req -in server.csr -text -noout >server.csr.txt
16
+ openssl x509 -in server.crt -noout -text >server.crt.txt
17
+ openssl verify -verbose -CAfile ca.crt server.crt
@@ -0,0 +1,20 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIDMzCCAhugAwIBAgIJAPDQ1Qe33NAsMA0GCSqGSIb3DQEBCwUAMFwxCzAJBgNV
3
+ BAYTAlVTMQ8wDQYDVQQIDAZEZW5pYWwxFDASBgNVBAcMC1NwcmluZ2ZpZWxkMQww
4
+ CgYDVQQKDANEaXMxGDAWBgNVBAMMD3d3dy5leGFtcGxlLmNvbTAeFw0xODA1MDEx
5
+ NDE1NThaFw0yODA0MjgxNDE1NThaMDYxDjAMBgNVBAoMBUdyb3VwMRAwDgYDVQQL
6
+ DAdZb3V0ZXN0MRIwEAYDVQQDDAlsb2NhbGhvc3QwggEiMA0GCSqGSIb3DQEBAQUA
7
+ A4IBDwAwggEKAoIBAQDT4hEyuc5GrsyhJJBSivKCYSB2eW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YO9d5xgFcgbUMY/qDSQQBVj9/vkcIRLT9fAsbdJKQ
21
+ vwXhzGjIDR5EIg6ZGD8I2QKBgBCKQcL9r/PcMdxHNeCqRtsdRUR619HUxgMh4aOc
22
+ oH0UmFSiBlv4xZTAwRelsCia8Sx3AC4yjf1KHwO+MS4N5tcWZ9hD0T5RbeRU20XM
23
+ N0v+Mvggr5pV+0DhsZygMd2tAqc3EBZX6eiivIxV/ZyCrCcPIO+JNPPmmsa5NzKo
24
+ 9QnhAoGAGg6hK2420UVZPKueSMXEkCzQCZERbVDNX5A98x7L7Ak5jva6VMb9dW/t
25
+ D15TH0XHe2tGFc+JW611Z0XeufV/BrrLY3ooDBzHNv8MqNNtxAZLqIJqGmcuKUxI
26
+ qpbNHppzujnsETh7klq7Fw6XmZCmIM4vkLJte8h0U58W+F60QnE=
27
+ -----END RSA PRIVATE KEY-----
@@ -0,0 +1,36 @@
1
+ require 'thin'
2
+ require 'em-http'
3
+ require 'json'
4
+
5
+ require_relative '../lib/ssl_gate'
6
+
7
+ config = {
8
+ bind_port: 9001,
9
+ target: 'http://localhost:9000',
10
+ private_key_file: File.dirname(__FILE__) + '/ssl/server.key',
11
+ cert_chain_file: File.dirname(__FILE__) + '/ssl/server.crt'
12
+ }
13
+
14
+ EventMachine.run do
15
+ Signal.trap('INT') { EM.stop if EM.reactor_running? }
16
+ Signal.trap('TERM') { EM.stop if EM.reactor_running? }
17
+
18
+ Thin::Server.start('0.0.0.0', 9000, signals: false) do
19
+ run lambda { |env| [200, { 'Content-Type' => 'application/javascript' }, [env.to_json]] }
20
+ end
21
+
22
+ SSLGate::HTTPServerAll.start config
23
+
24
+ EM.add_timer(1) do
25
+ 10.times do
26
+ http = EM::HttpRequest.new('https://localhost:9001/path1?p1=v1&p2=v2').get
27
+ http.callback {
28
+ puts "#{http.response_header.status} - #{http.response.length} bytes\n"
29
+ puts http.response
30
+ }
31
+ http.errback { puts http.error }
32
+ end
33
+ end
34
+
35
+ EM.add_timer(3) { EM.stop }
36
+ end
@@ -0,0 +1,37 @@
1
+ require_relative '../lib/ssl_gate'
2
+
3
+ config = {
4
+ bind_port: 9001,
5
+ target: 'tcp://localhost:9000',
6
+ private_key_file: File.dirname(__FILE__) + '/ssl/server.key',
7
+ cert_chain_file: File.dirname(__FILE__) + '/ssl/server.crt'
8
+ }
9
+
10
+ EventMachine.run do
11
+ Signal.trap('INT') { EM.stop if EM.reactor_running? }
12
+ Signal.trap('TERM') { EM.stop if EM.reactor_running? }
13
+
14
+ EM.start_server '0.0.0.0', 9000 do |srv|
15
+ def srv.receive_data(data)
16
+ send_data ">>> you sent: #{data}"
17
+ end
18
+ end
19
+
20
+ SSLGate::RawServerAll.start config
21
+
22
+ EM.add_timer(1) do
23
+ 10.times do
24
+ EventMachine.connect '127.0.0.1', 9001 do |c|
25
+ c.start_tls
26
+ def c.ssl_handshake_completed
27
+ send_data 'Hello'
28
+ end
29
+ def c.receive_data(data)
30
+ p data
31
+ end
32
+ end
33
+ end
34
+ end
35
+
36
+ EM.add_timer(3) { EM.stop }
37
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ssl_gate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Artyom B
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-28 00:00:00.000000000 Z
11
+ date: 2018-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: em-http-request
@@ -82,10 +82,19 @@ files:
82
82
  - lib/ssl_gate/raw_gate.rb
83
83
  - lib/ssl_gate/raw_ssl.rb
84
84
  - lib/ssl_gate/runner.rb
85
- homepage: http://rubygems.org/gems/ssl_gate
85
+ - test/ssl/ca.crt
86
+ - test/ssl/ca.key
87
+ - test/ssl/make_ca.sh
88
+ - test/ssl/make_server.sh
89
+ - test/ssl/server.crt
90
+ - test/ssl/server.key
91
+ - test/test.rb
92
+ - test/test_raw.rb
93
+ homepage: https://rubygems.org/gems/ssl_gate
86
94
  licenses:
87
95
  - Nonstandard
88
- metadata: {}
96
+ metadata:
97
+ source_code_uri: https://github.com/artyomb/ssl_gate
89
98
  post_install_message:
90
99
  rdoc_options: []
91
100
  require_paths: