right_http_connection 1.2.3 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,64 @@
1
+ #-- -*- mode: ruby; encoding: utf-8 -*-
2
+ # Copyright: Copyright (c) 2011 RightScale, Inc.
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # 'Software'), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18
+ # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19
+ # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20
+ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21
+ # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #++
23
+
24
+ require 'rubygems'
25
+ require 'rake'
26
+ require 'rake/clean'
27
+
28
+ file "passphrase.txt" do
29
+ File.open("passphrase.txt", "w") { |f| f.puts "foobar" }
30
+ end
31
+
32
+ file "ca.key" => "passphrase.txt" do |t|
33
+ sh("openssl", "req", "-new", "-x509", "-extensions", "v3_ca",
34
+ "-keyout", "ca.key", "-out", "ca.crt", "-days", "1825",
35
+ "-passout", "file:#{t.prerequisites[0]}")
36
+ end
37
+
38
+ file "ca.crt" => "ca.key"
39
+
40
+ file "server.key" do |t|
41
+ sh("openssl", "req", "-new", "-nodes", "-keyout", t.name,
42
+ "-out", "server.csr", "-days", "365")
43
+ end
44
+ file "server.csr" => "server.key"
45
+
46
+ directory "demoCA"
47
+ file "demoCA/index.txt" => "demoCA" do
48
+ sh "touch", "demoCA/index.txt"
49
+ end
50
+ file "demoCA/serial" => "demoCA" do
51
+ File.open("demoCA/serial", "w") {|f| f.puts "01"}
52
+ end
53
+
54
+ file "server.crt" => ["server.csr", "ca.key", "passphrase.txt", "demoCA/index.txt", "demoCA/serial"] do |t|
55
+ sh("openssl", "ca", "-policy", "policy_anything", "-out", t.name,
56
+ "-outdir", ".",
57
+ "-cert", "ca.crt", "-keyfile", "ca.key", "-passin", "file:passphrase.txt",
58
+ "-infiles", "server.csr")
59
+ end
60
+
61
+ task :default => ["ca.crt", "server.crt", "server.key"] do |t|
62
+ sh("cp", *(t.prerequisites + [".."]))
63
+ sh "cp", "ca.crt", "../good.ca"
64
+ end
@@ -0,0 +1,23 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIID6TCCA1KgAwIBAgIJAMbnbxA3pDCfMA0GCSqGSIb3DQEBBQUAMIGqMQswCQYD
3
+ VQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FudGEgQmFy
4
+ YmFyYTEZMBcGA1UEChMQUmlnaHRTY2FsZSwgSW5jLjEVMBMGA1UECxMMQXp1cmUg
5
+ U3ByaW50MRYwFAYDVQQDEw1BenVyZSB0ZXN0IENBMSQwIgYJKoZIhvcNAQkBFhVn
6
+ cmFoYW1AcmlnaHRzY2FsZS5jb20wHhcNMTEwMjAxMDIzNjU2WhcNMTYwMTMxMDIz
7
+ NjU2WjCBqjELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNV
8
+ BAcTDVNhbnRhIEJhcmJhcmExGTAXBgNVBAoTEFJpZ2h0U2NhbGUsIEluYy4xFTAT
9
+ BgNVBAsTDEF6dXJlIFNwcmludDEWMBQGA1UEAxMNQXp1cmUgdGVzdCB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/ctKYKBm27qlFraLz+Vnkj0fMW8yHzY+We
6
+ 8517Kl82vytZhTjnU6Elw6RpfgJzs0TnP5OhvLBsmNEXpHymNCcGt7p8jJopHEaa
7
+ 8IT87WqKqryyEjbkEFqCb0QfwLBd9PVT+lQeEcPAHlMkC8lwkjVCAsvJaZ3GsURJ
8
+ Tb5xHOYj0jccm/xrg82e/25emMqTGCBKwb7cTyyKxmL8ezi1vA9jJcf9M7KgNgUA
9
+ FGo7mrCK9niHfOLULD8f3WN+2DHoTwIDXseNWS/giSePQZZupVmWEUtDkt2x9qCb
10
+ nJat/ESncAU1BrqXiYTpdtgao/TXcpt+7w/DMLHbOxus7p9sqZnAcXc/0Y+ZsYF1
11
+ rq0spVpgJfDU6sP0ay61rOf7YnTko0oewiF0/c+dB42XErkM88wupNHJfr+M2Cfg
12
+ w8BQeCx1l14W2haWlTgstBhfGWod76CT7Ng7/927L7P3pJ5ebS7qWRMskJGFMCFV
13
+ 9rd7OjGiYEqB365YI0VUiZPkXE9bXxRyfnU6K7hVtR3kY+TYADEgcaDE+6W1bgOc
14
+ jwEeObdDqRbAR/YD/3myhvRF9k7C/fQ5PqOC3dlQZTXQCAJYCt9aNXkxBnMmh1WS
15
+ GDDUpF9s6lSoUFm+yic4RXNX9Jj5npUKZR1TBqZfHQjzRLxEKxQo6VESa5QEWkM0
16
+ C2Rsmxs/3dXXTJTOrP9rzWhQmxdCz7n4efHEHuMuVXvRtEAFjMrKfcH1t5fFQ8fA
17
+ sBrulv26/ygJFwZrSfq7ILW/AcYFEMmQflLGoVJ8aiSl4oBwIS7FvA==
18
+ -----END RSA PRIVATE KEY-----
@@ -0,0 +1 @@
1
+ V 120201024841Z 01 unknown /C=US/ST=California/L=Santa Barbara/O=RightScale, Inc./OU=Azure Sprint/CN=127.0.0.1
@@ -0,0 +1 @@
1
+ 02
@@ -0,0 +1 @@
1
+ foobar
@@ -0,0 +1,12 @@
1
+ -----BEGIN CERTIFICATE REQUEST-----
2
+ MIIBwTCCAS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QHJpZ2h0c2NhbGUuY29tMIGfMA0GCSqGSIb3DQEB
11
+ AQUAA4GNADCBiQKBgQDha7yTsOMojuy/4RvZqPlPNxQj2AAhEIFONvMcSTXBwlND
12
+ xtOXHzF963LxBrxqOXnCMvfSBnzsfywS6k8dGwBpxoiG420QK6SZ0X3DEwzBXVX7
13
+ jnxQICtMzFO/h/AYhuNbzeAPwzrnRKNhqJGLuKOKga7Z6+ZyyXtKIf2+apjO+wID
14
+ AQABo4IBEzCCAQ8wHQYDVR0OBBYEFL4IVWcPJhd11ajwbIT2va3O5XhpMIHfBgNV
15
+ HSMEgdcwgdSAFL4IVWcPJhd11ajwbIT2va3O5XhpoYGwpIGtMIGqMQswCQYDVQQG
16
+ EwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FudGEgQmFyYmFy
17
+ YTEZMBcGA1UEChMQUmlnaHRTY2FsZSwgSW5jLjEVMBMGA1UECxMMQXp1cmUgU3By
18
+ aW50MRYwFAYDVQQDEw1BenVyZSB0ZXN0IENBMSQwIgYJKoZIhvcNAQkBFhVncmFo
19
+ YW1AcmlnaHRzY2FsZS5jb22CCQDG528QN6QwnzAMBgNVHRMEBTADAQH/MA0GCSqG
20
+ SIb3DQEBBQUAA4GBADbJoPLdHiwR3RQ9mrKUgxdCv14BLvg1UAP6QhU1Y8TIUxAp
21
+ HljbEHYk/B9PoG9GsdxTlnFu7LJVOZB7c+aFOaMyRR4TUUwPm/AGMMFnZMbnecqD
22
+ Y9JV2y0mn10i6er9Lz19CGi9TlOUuNdYKLT9cTCaqaVFPvXk44sNb3/5mrpi
23
+ -----END CERTIFICATE-----
@@ -0,0 +1,75 @@
1
+ #-- -*- mode: ruby; encoding: utf-8 -*-
2
+ # Copyright: Copyright (c) 2011 RightScale, Inc.
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # 'Software'), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18
+ # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19
+ # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20
+ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21
+ # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #++
23
+
24
+ require 'rubygems'
25
+ require 'bundler/setup'
26
+ require 'trollop'
27
+ require 'webrick/httpproxy'
28
+ require 'webrick/httpauth'
29
+ require 'cgi'
30
+
31
+ # Patch broken WEBrick escape
32
+ module WEBrick::HTMLUtils
33
+ def escape(string)
34
+ CGI.escapeHTML(string.to_s)
35
+ end
36
+ module_function :escape
37
+ end
38
+
39
+ opts = Trollop::options do
40
+ version "proxy_server 0.1 (c) 2011 RightScale, Inc."
41
+ banner <<-EOS
42
+ Run a very simple proxy server for debugging.
43
+
44
+ Usage:
45
+ proxy_server [options]
46
+ where [options] are:
47
+ EOS
48
+ opt :username, "Username to use for authentication", :type => :string
49
+ opt :password, "Password to use for authentication", :type => :string
50
+ opt :port, "Port to use", :default => 9090
51
+ opt :disable_connect, "Whether to disable using CONNECT through the proxy"
52
+ end
53
+
54
+ logger = WEBrick::Log.new($stderr, WEBrick::Log::WARN)
55
+ config = {}
56
+ config[:Port] = opts[:port]
57
+ config[:Logger] = logger
58
+ config[:AccessLog] = [[$stdout, WEBrick::AccessLog::COMBINED_LOG_FORMAT]]
59
+ config[:ProxyAuthProc] = Proc.new do |req, res|
60
+ if opts[:disable_connect] && req.request_method == "CONNECT"
61
+ raise WEBrick::HTTPStatus::Forbidden
62
+ end
63
+
64
+ unless opts[:username].nil? || opts[:password].nil?
65
+ WEBrick::HTTPAuth.proxy_basic_auth(req, res, "Test realm") {|user, pass|
66
+ user == opts[:username] && pass == opts[:password]
67
+ }
68
+ end
69
+ end
70
+ $stdout.sync = true
71
+ server = WEBrick::HTTPProxyServer.new(config)
72
+ ['INT', 'TERM'].each {|signal|
73
+ trap(signal) { server.shutdown }
74
+ }
75
+ server.start
@@ -0,0 +1,122 @@
1
+ #-- -*- mode: ruby; encoding: utf-8 -*-
2
+ # Copyright: Copyright (c) 2011 RightScale, Inc.
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # 'Software'), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18
+ # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19
+ # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20
+ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21
+ # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #++
23
+
24
+ require 'webrick'
25
+
26
+ ssl_cert, ssl_key, ca_cert = ARGV[0], ARGV[1], ARGV[2]
27
+
28
+ # Monkey patch bad User-Agent parsing
29
+ module WEBrick::AccessLog
30
+ module_function
31
+
32
+ def format(format_string, params)
33
+ format_string.gsub(/\%(?:\{(.*?)\})?>?([a-zA-Z%])/){
34
+ param, spec = $1, $2
35
+ case spec[0]
36
+ when ?e, ?i, ?n, ?o
37
+ raise AccessLogError,
38
+ "parameter is required for \"#{spec}\"" unless param
39
+ if params[spec][param]
40
+ escape(params[spec][param])
41
+ else
42
+ "-"
43
+ end
44
+ when ?t
45
+ params[spec].strftime(param || CLF_TIME_FORMAT)
46
+ when ?%
47
+ "%"
48
+ else
49
+ escape(params[spec].to_s)
50
+ end
51
+ }
52
+ end
53
+ end
54
+
55
+ logger = WEBrick::Log.new($stderr, WEBrick::Log::WARN)#WEBrick::Log::DEBUG
56
+ config = {}
57
+ config[:Port] = 7890
58
+ config[:Logger] = logger
59
+ config[:AccessLog] = [[$stdout, WEBrick::AccessLog::COMBINED_LOG_FORMAT]]
60
+ unless ssl_cert.nil? || ssl_key.nil?
61
+ require 'webrick/https'
62
+ config[:SSLEnable] = true
63
+ # http://www.openssl.org/docs/ssl/SSL_CTX_set_verify.html#
64
+ # SSL_VERIFY_FAIL_IF_NO_PEER_CERT
65
+ # => Server mode: if the client did not return a certificate, the TLS/SSL handshake is immediately terminated with a 'handshake failure' alert.
66
+ # => This flag must be used together with SSL_VERIFY_PEER.
67
+ config[:SSLVerifyClient] = OpenSSL::SSL::VERIFY_PEER
68
+ config[:SSLVerifyClient] |= OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT if ca_cert
69
+ config[:SSLPrivateKey] = OpenSSL::PKey::RSA.new(File.open(ssl_key).read)
70
+ config[:SSLCertificate] = OpenSSL::X509::Certificate.new(File.open(ssl_cert).read)
71
+ # KHRVI: option config[:SSLCertName] does make sense only when config[:SSLCertificate] isn't specified
72
+ # see: webrick/ssl.rb method :setup_ssl_context
73
+ # config[:SSLCertName] = [["CN", "Graham Hughes"]]
74
+ config[:SSLVerifyDepth] = 9
75
+ config[:SSLCACertificateFile] = ca_cert if ca_cert
76
+ end
77
+ $stdout.sync = true
78
+ server = WEBrick::HTTPServer.new(config)
79
+
80
+ server.mount_proc('/good') {|req, resp|
81
+ resp.status = 200
82
+ resp['Content-Type'] = "text/plain"
83
+ resp.body = "good"
84
+ }
85
+ intermittent_times = 0
86
+ server.mount_proc('/intermittent-hang') {|req, resp|
87
+ intermittent_times += 1
88
+ if intermittent_times % 2 == 1
89
+ sleep 5
90
+ resp.status = 403
91
+ resp['Content-Type'] = "text/plain"
92
+ resp.body = "bad"
93
+ else
94
+ resp.status = 200
95
+ resp['Content-Type'] = "text/plain"
96
+ resp.body = "good"
97
+ end
98
+ }
99
+ server.mount_proc('/hang') {|req, resp|
100
+ sleep 5
101
+ resp.status = 200
102
+ resp['Content-Type'] = "text/plain"
103
+ resp.body = "good"
104
+ }
105
+ server.mount_proc('/ugly') {|req, resp|
106
+ resp.status = 404
107
+ resp['Content-Type'] = "text/plain"
108
+ resp.body = "ugly"
109
+ }
110
+ server.mount_proc('/filename') {|req, resp|
111
+ resp.status = 200
112
+ resp['ETag'] = File.stat('filename').mtime
113
+ resp['Content-Type'] = "text/plain"
114
+ resp.body = File.open("filename").read
115
+ }
116
+
117
+ # trap signals to invoke shutdown cleanly
118
+ ['INT', 'TERM'].each { |signal|
119
+ trap(signal) { server.shutdown }
120
+ }
121
+
122
+ server.start
@@ -0,0 +1,62 @@
1
+ Certificate:
2
+ Data:
3
+ Version: 3 (0x2)
4
+ Serial Number: 1 (0x1)
5
+ Signature Algorithm: sha1WithRSAEncryption
6
+ Issuer: C=US, ST=California, L=Santa Barbara, O=RightScale, Inc., OU=Azure Sprint, CN=Azure test CA/emailAddress=graham@rightscale.com
7
+ Validity
8
+ Not Before: Feb 1 02:48:41 2011 GMT
9
+ Not After : Feb 1 02:48:41 2012 GMT
10
+ Subject: C=US, ST=California, L=Santa Barbara, O=RightScale, Inc., OU=Azure Sprint, CN=127.0.0.1
11
+ Subject Public Key Info:
12
+ Public Key Algorithm: rsaEncryption
13
+ RSA Public Key: (1024 bit)
14
+ Modulus (1024 bit):
15
+ 00:be:0c:ee:7f:8f:c9:c9:a3:4a:dd:50:bb:7a:28:
16
+ d4:93:4b:82:b4:9e:87:58:89:d8:ce:0a:e9:5f:f5:
17
+ f1:99:fd:0f:a3:a9:d9:e9:19:58:e1:88:8f:2f:d6:
18
+ 2d:a9:a3:cb:5e:e4:fe:18:39:03:0e:c3:8c:01:90:
19
+ c1:16:c3:db:8a:28:99:33:84:13:a9:6f:1e:d6:18:
20
+ 8c:f3:18:3a:c3:fc:2b:7f:fa:1f:05:a9:23:4e:c8:
21
+ a4:dc:e6:b4:90:85:82:b3:57:32:98:bb:04:64:93:
22
+ 09:b2:81:fd:0a:9a:03:19:4b:c0:e3:b0:01:41:59:
23
+ 12:ab:4d:05:e8:80:05:d2:bf
24
+ Exponent: 65537 (0x10001)
25
+ X509v3 extensions:
26
+ X509v3 Basic Constraints:
27
+ CA:FALSE
28
+ Netscape Comment:
29
+ OpenSSL Generated Certificate
30
+ X509v3 Subject Key Identifier:
31
+ 53:2D:31:08:5D:F7:AC:1F:0B:05:68:9D:02:16:EE:A8:95:58:B3:B7
32
+ X509v3 Authority Key Identifier:
33
+ keyid:BE:08:55:67:0F:26:17:75:D5:A8:F0:6C:84:F6:BD:AD:CE:E5:78:69
34
+
35
+ Signature Algorithm: sha1WithRSAEncryption
36
+ 24:7e:c8:da:b9:bb:f8:ab:49:cb:cc:58:39:51:eb:e4:70:0f:
37
+ 1c:18:19:f3:91:54:9e:7a:9f:9b:9b:02:e2:83:81:6f:0b:c6:
38
+ d6:15:e7:22:f3:0b:72:01:fa:d2:1a:f9:17:57:15:aa:fb:f6:
39
+ 1f:d2:9d:ef:45:23:58:66:38:c1:ad:f0:c9:9e:c0:d7:7c:17:
40
+ f1:1e:f9:6b:bd:52:48:8b:ac:80:89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