ajmurmann_right_http_connection 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +62 -0
- data/Manifest.txt +8 -0
- data/README.txt +66 -0
- data/Rakefile +89 -0
- data/lib/net_fix.rb +160 -0
- data/lib/right_http_connection.rb +479 -0
- data/lib/support.rb +109 -0
- data/lib/version.rb +32 -0
- data/right_http_connection.gemspec +63 -0
- data/spec/bad.ca +2794 -0
- data/spec/ca/Rakefile +64 -0
- data/spec/ca/ca.crt +23 -0
- data/spec/ca/ca.key +18 -0
- data/spec/ca/demoCA/index.txt +1 -0
- data/spec/ca/demoCA/serial +1 -0
- data/spec/ca/passphrase.txt +1 -0
- data/spec/ca/server.csr +12 -0
- data/spec/good.ca +23 -0
- data/spec/proxy_server.rb +75 -0
- data/spec/really_dumb_webserver.rb +113 -0
- data/spec/server.crt +62 -0
- data/spec/server.key +15 -0
- metadata +181 -0
data/spec/ca/Rakefile
ADDED
@@ -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
|
data/spec/ca/ca.crt
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
MIID6TCCA1KgAwIBAgIJAMbnbxA3pDCfMA0GCSqGSIb3DQEBBQUAMIGqMQswCQYD
|
3
|
+
VQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FudGEgQmFy
|
4
|
+
YmFyYTEZMBcGA1UEChMQUmlnaHRTY2FsZSwgSW5jLjEVMBMGA1UECxMMQXp1cmUg
|
5
|
+
U3ByaW50MRYwFAYDVQQDEw1BenVyZSB0ZXN0IENBMSQwIgYJKoZIhvcNAQkBFhVn
|
6
|
+
cmFoYW1AcmlnaHRzY2FsZS5jb20wHhcNMTEwMjAxMDIzNjU2WhcNMTYwMTMxMDIz
|
7
|
+
NjU2WjCBqjELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNV
|
8
|
+
BAcTDVNhbnRhIEJhcmJhcmExGTAXBgNVBAoTEFJpZ2h0U2NhbGUsIEluYy4xFTAT
|
9
|
+
BgNVBAsTDEF6dXJlIFNwcmludDEWMBQGA1UEAxMNQXp1cmUgdGVzdCBDQTEkMCIG
|
10
|
+
CSqGSIb3DQEJARYVZ3JhaGFtQHJpZ2h0c2NhbGUuY29tMIGfMA0GCSqGSIb3DQEB
|
11
|
+
AQUAA4GNADCBiQKBgQDha7yTsOMojuy/4RvZqPlPNxQj2AAhEIFONvMcSTXBwlND
|
12
|
+
xtOXHzF963LxBrxqOXnCMvfSBnzsfywS6k8dGwBpxoiG420QK6SZ0X3DEwzBXVX7
|
13
|
+
jnxQICtMzFO/h/AYhuNbzeAPwzrnRKNhqJGLuKOKga7Z6+Zy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
+
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
|
data/spec/ca/server.csr
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
-----BEGIN CERTIFICATE REQUEST-----
|
2
|
+
MIIBwTCCASoCAQAwgYAxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlh
|
3
|
+
MRYwFAYDVQQHE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VOZB7c+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,113 @@
|
|
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 = ARGV[0], ARGV[1]
|
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)
|
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
|
+
config[:SSLVerifyClient] = OpenSSL::SSL::VERIFY_NONE
|
64
|
+
config[:SSLPrivateKey] = OpenSSL::PKey::RSA.new(File.open(ssl_key).read)
|
65
|
+
config[:SSLCertificate] = OpenSSL::X509::Certificate.new(File.open(ssl_cert).read)
|
66
|
+
config[:SSLCertName] = [["CN", "Graham Hughes"]]
|
67
|
+
end
|
68
|
+
$stdout.sync = true
|
69
|
+
server = WEBrick::HTTPServer.new(config)
|
70
|
+
|
71
|
+
server.mount_proc('/good') {|req, resp|
|
72
|
+
resp.status = 200
|
73
|
+
resp['Content-Type'] = "text/plain"
|
74
|
+
resp.body = "good"
|
75
|
+
}
|
76
|
+
intermittent_times = 0
|
77
|
+
server.mount_proc('/intermittent-hang') {|req, resp|
|
78
|
+
intermittent_times += 1
|
79
|
+
if intermittent_times % 2 == 1
|
80
|
+
sleep 5
|
81
|
+
resp.status = 403
|
82
|
+
resp['Content-Type'] = "text/plain"
|
83
|
+
resp.body = "bad"
|
84
|
+
else
|
85
|
+
resp.status = 200
|
86
|
+
resp['Content-Type'] = "text/plain"
|
87
|
+
resp.body = "good"
|
88
|
+
end
|
89
|
+
}
|
90
|
+
server.mount_proc('/hang') {|req, resp|
|
91
|
+
sleep 5
|
92
|
+
resp.status = 200
|
93
|
+
resp['Content-Type'] = "text/plain"
|
94
|
+
resp.body = "good"
|
95
|
+
}
|
96
|
+
server.mount_proc('/ugly') {|req, resp|
|
97
|
+
resp.status = 404
|
98
|
+
resp['Content-Type'] = "text/plain"
|
99
|
+
resp.body = "ugly"
|
100
|
+
}
|
101
|
+
server.mount_proc('/filename') {|req, resp|
|
102
|
+
resp.status = 200
|
103
|
+
resp['ETag'] = File.stat('filename').mtime
|
104
|
+
resp['Content-Type'] = "text/plain"
|
105
|
+
resp.body = File.open("filename").read
|
106
|
+
}
|
107
|
+
|
108
|
+
# trap signals to invoke shutdown cleanly
|
109
|
+
['INT', 'TERM'].each { |signal|
|
110
|
+
trap(signal) { server.shutdown }
|
111
|
+
}
|
112
|
+
|
113
|
+
server.start
|
data/spec/server.crt
ADDED
@@ -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:41:35:10:d4:a1:c8:68:
|
41
|
+
6e:87:e7:18:45:31:ff:35:a7:57:07:c1:aa:54:75:b2:78:f2:
|
42
|
+
3d:7d:33:38:7f:71:4a:4f:ee:ed:d8:ca:cb:f3:8e:01:41:44:
|
43
|
+
2a:3f
|
44
|
+
-----BEGIN CERTIFICATE-----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Awo
|
13
|
+
HBIPW7IDK+gEaQx4mxsCQQCpuseeUqAuZXlzedbff5KBq0RcrzzEgRZCGyDM/uPU
|
14
|
+
boj87H/49H68OZmPzER+hHTbo5pYSOI3A9v5XmOOORxb
|
15
|
+
-----END RSA PRIVATE KEY-----
|
metadata
ADDED
@@ -0,0 +1,181 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ajmurmann_right_http_connection
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 1.3.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- RightScale, Inc.
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-02-26 00:00:00 -08:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rake
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rspec
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 5
|
44
|
+
segments:
|
45
|
+
- 2
|
46
|
+
- 3
|
47
|
+
version: "2.3"
|
48
|
+
type: :development
|
49
|
+
version_requirements: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: cucumber
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ~>
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
hash: 27
|
59
|
+
segments:
|
60
|
+
- 0
|
61
|
+
- 8
|
62
|
+
version: "0.8"
|
63
|
+
type: :development
|
64
|
+
version_requirements: *id003
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
name: flexmock
|
67
|
+
prerelease: false
|
68
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ~>
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
hash: 41
|
74
|
+
segments:
|
75
|
+
- 0
|
76
|
+
- 8
|
77
|
+
- 11
|
78
|
+
version: 0.8.11
|
79
|
+
type: :development
|
80
|
+
version_requirements: *id004
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: trollop
|
83
|
+
prerelease: false
|
84
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
hash: 47
|
90
|
+
segments:
|
91
|
+
- 1
|
92
|
+
- 16
|
93
|
+
version: "1.16"
|
94
|
+
type: :development
|
95
|
+
version_requirements: *id005
|
96
|
+
description: |
|
97
|
+
Rightscale::HttpConnection is a robust HTTP/S library. It implements a retry
|
98
|
+
algorithm for low-level network errors.
|
99
|
+
|
100
|
+
== FEATURES:
|
101
|
+
|
102
|
+
- provides put/get streaming
|
103
|
+
- does configurable retries on connect and read timeouts, DNS failures, etc.
|
104
|
+
- HTTPS certificate checking
|
105
|
+
|
106
|
+
email: rubygems@rightscale.com
|
107
|
+
executables: []
|
108
|
+
|
109
|
+
extensions: []
|
110
|
+
|
111
|
+
extra_rdoc_files:
|
112
|
+
- README.txt
|
113
|
+
files:
|
114
|
+
- History.txt
|
115
|
+
- Manifest.txt
|
116
|
+
- README.txt
|
117
|
+
- Rakefile
|
118
|
+
- lib/net_fix.rb
|
119
|
+
- lib/right_http_connection.rb
|
120
|
+
- lib/support.rb
|
121
|
+
- lib/version.rb
|
122
|
+
- right_http_connection.gemspec
|
123
|
+
- spec/bad.ca
|
124
|
+
- spec/ca/Rakefile
|
125
|
+
- spec/ca/ca.crt
|
126
|
+
- spec/ca/ca.key
|
127
|
+
- spec/ca/demoCA/index.txt
|
128
|
+
- spec/ca/demoCA/serial
|
129
|
+
- spec/ca/passphrase.txt
|
130
|
+
- spec/ca/server.csr
|
131
|
+
- spec/good.ca
|
132
|
+
- spec/proxy_server.rb
|
133
|
+
- spec/really_dumb_webserver.rb
|
134
|
+
- spec/server.crt
|
135
|
+
- spec/server.key
|
136
|
+
has_rdoc: true
|
137
|
+
homepage: http://rightscale.rubyforge.org/
|
138
|
+
licenses: []
|
139
|
+
|
140
|
+
post_install_message:
|
141
|
+
rdoc_options:
|
142
|
+
- --quiet
|
143
|
+
- --main
|
144
|
+
- README.txt
|
145
|
+
- --title
|
146
|
+
- right_http_connection documentation
|
147
|
+
- --opname
|
148
|
+
- index.html
|
149
|
+
- --line-numbers
|
150
|
+
- --inline-source
|
151
|
+
require_paths:
|
152
|
+
- lib
|
153
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
154
|
+
none: false
|
155
|
+
requirements:
|
156
|
+
- - ">="
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
hash: 57
|
159
|
+
segments:
|
160
|
+
- 1
|
161
|
+
- 8
|
162
|
+
- 7
|
163
|
+
version: 1.8.7
|
164
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
|
+
none: false
|
166
|
+
requirements:
|
167
|
+
- - ">="
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
hash: 3
|
170
|
+
segments:
|
171
|
+
- 0
|
172
|
+
version: "0"
|
173
|
+
requirements: []
|
174
|
+
|
175
|
+
rubyforge_project: rightscale
|
176
|
+
rubygems_version: 1.3.7
|
177
|
+
signing_key:
|
178
|
+
specification_version: 3
|
179
|
+
summary: RightScale's robust HTTP/S connection module
|
180
|
+
test_files: []
|
181
|
+
|