rubygems_ssl-client-certs 0.0.1.pre.alpha.pre.35 → 0.0.2.pre.alpha.pre.51
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.gitignore +1 -0
- data/.travis.yml +3 -0
- data/lib/rubygems_plugin.rb +98 -79
- data/lib/rubygems_ssl-client-certs/version.rb +1 -1
- data/rubygems_ssl-client-certs.gemspec +1 -1
- data/spec/gem_remote_fetcher_spec.rb +8 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZjI1NTFmNDE5NjU5YmE5ZDU0N2ViNmM1YjNmM2Y2OGYxOWEzNGE0Yw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NGE3NTM2NTJmNjUxYjRjZDk5N2I1OWZlYzZkN2NlZjcxYTFjNDViOQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MWYyZGQ2ZDM0OTc5MTJiN2VjMjI5OTYxZGIxN2MzMGJlZmU1M2FjOTMwOTRh
|
10
|
+
M2RkMTU4YjIwMDQ0ZjNjMTE5MmM2ZDJhZmQxMzdlOTAzNzg0ZDMxMWFkMzI2
|
11
|
+
NTE0YmJmOGRiODRjMDY1ZTNkODgxMzg1Y2QxOWUxNzk5MjdhNGM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NzI2NWM2ODg3ODVlNDlkZDU2MWFlZWFjMmMzZTk0NjY1Zjk3OTE0NDgxNWYw
|
14
|
+
ODE5M2IwODBkYTg0NzkxYTNiYTY2YTViMzk2ODg4NzRmZWFiNTI4ZmY1MDI2
|
15
|
+
MzVmMDMzYzU4MmE4YTU4MjQxMWY5OGE0MWEzM2Q4OTQxMmVhMDM=
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/lib/rubygems_plugin.rb
CHANGED
@@ -1,108 +1,127 @@
|
|
1
1
|
require 'rubygems/remote_fetcher'
|
2
2
|
|
3
|
-
|
3
|
+
$stderr.puts "rubygems ssl client certs plugin loading"
|
4
4
|
|
5
|
-
|
5
|
+
if Gem::Version.new(Gem::VERSION) < Gem::Version.new('2.1.0') then
|
6
6
|
|
7
|
-
|
7
|
+
class Gem::Version
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
class << self
|
12
|
-
unless self.method_defined? :__new__
|
13
|
-
alias_method :__new__, :new
|
14
|
-
end
|
15
|
-
def new(*args)
|
16
|
-
config = __new__(*args)
|
17
|
-
config.set_ssl_vars
|
18
|
-
return config
|
9
|
+
def self.correct? version
|
10
|
+
version.to_s =~ /\A\s*([0-9]+(?>\.[0-9a-zA-Z]+)*(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?)?\s*\z/
|
19
11
|
end
|
20
|
-
end
|
21
12
|
|
22
|
-
def set_ssl_vars
|
23
|
-
@ssl_verify_mode = @hash[:ssl_verify_mode] if @hash.key? :ssl_verify_mode
|
24
|
-
@ssl_ca_cert = @hash[:ssl_ca_cert] if @hash.key? :ssl_ca_cert
|
25
|
-
@ssl_ca_cert = ENV['BUNDLE_SSL_CA_CERT'] unless @ssl_ca_cert
|
26
|
-
@ssl_client_cert = @hash[:ssl_client_cert] if @hash.key? :ssl_client_cert
|
27
|
-
@ssl_client_cert = ENV['BUNDLE_SSL_CLIENT_CERT'] unless @ssl_client_cert
|
28
13
|
end
|
29
14
|
|
30
|
-
|
15
|
+
class Gem::ConfigFile
|
31
16
|
|
32
|
-
|
17
|
+
attr_reader :ssl_client_cert
|
33
18
|
|
34
|
-
|
35
|
-
net_http_args = [uri.host, uri.port]
|
19
|
+
attr_reader :ssl_verify_mode
|
36
20
|
|
37
|
-
|
38
|
-
|
39
|
-
@proxy_uri.host,
|
40
|
-
@proxy_uri.port,
|
41
|
-
@proxy_uri.user,
|
42
|
-
@proxy_uri.password
|
43
|
-
]
|
44
|
-
end
|
45
|
-
|
46
|
-
connection_id = [Thread.current.object_id, *net_http_args].join ':'
|
47
|
-
@connections[connection_id] ||= Net::HTTP.new(*net_http_args)
|
48
|
-
connection = @connections[connection_id]
|
21
|
+
attr_reader :ssl_ca_cert
|
22
|
+
$stderr.puts "loading Gem::ConfigFile monkey patch"
|
49
23
|
|
50
|
-
|
51
|
-
|
24
|
+
class << self
|
25
|
+
unless self.method_defined? :__new__
|
26
|
+
alias_method :__new__, :new
|
27
|
+
end
|
28
|
+
def new(*args)
|
29
|
+
$stderr.puts "instantiating new Gem::ConfigFile with patch"
|
30
|
+
config = __new__(*args)
|
31
|
+
config.set_ssl_vars
|
32
|
+
return config
|
33
|
+
end
|
52
34
|
end
|
53
35
|
|
54
|
-
|
36
|
+
def set_ssl_vars
|
37
|
+
$stderr.puts "Configuring SSL variables for Gem::ConfigFile"
|
38
|
+
@ssl_verify_mode = @hash[:ssl_verify_mode] if @hash.key? :ssl_verify_mode
|
39
|
+
@ssl_ca_cert = @hash[:ssl_ca_cert] if @hash.key? :ssl_ca_cert
|
40
|
+
@ssl_ca_cert = ENV['BUNDLE_SSL_CA_CERT'] unless @ssl_ca_cert
|
41
|
+
@ssl_client_cert = @hash[:ssl_client_cert] if @hash.key? :ssl_client_cert
|
42
|
+
@ssl_client_cert = ENV['BUNDLE_SSL_CLIENT_CERT'] unless @ssl_client_cert
|
43
|
+
end
|
55
44
|
|
56
|
-
connection
|
57
|
-
rescue defined?(OpenSSL::SSL) ? OpenSSL::SSL::SSLError : Errno::EHOSTDOWN,
|
58
|
-
Errno::EHOSTDOWN => e
|
59
|
-
raise FetchError.new(e.message, uri)
|
60
45
|
end
|
61
46
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
47
|
+
class Gem::RemoteFetcher
|
48
|
+
|
49
|
+
def connection_for(uri)
|
50
|
+
net_http_args = [uri.host, uri.port]
|
51
|
+
|
52
|
+
if @proxy_uri and not no_proxy?(uri.host) then
|
53
|
+
net_http_args += [
|
54
|
+
@proxy_uri.host,
|
55
|
+
@proxy_uri.port,
|
56
|
+
@proxy_uri.user,
|
57
|
+
@proxy_uri.password
|
58
|
+
]
|
59
|
+
end
|
60
|
+
|
61
|
+
connection_id = [Thread.current.object_id, *net_http_args].join ':'
|
62
|
+
@connections[connection_id] ||= Net::HTTP.new(*net_http_args)
|
63
|
+
connection = @connections[connection_id]
|
64
|
+
|
65
|
+
if https?(uri) and not connection.started? then
|
66
|
+
configure_connection_for_https(connection)
|
67
|
+
end
|
68
|
+
|
69
|
+
connection.start unless connection.started?
|
70
|
+
|
71
|
+
connection
|
72
|
+
rescue defined?(OpenSSL::SSL) ? OpenSSL::SSL::SSLError : Errno::EHOSTDOWN,
|
73
|
+
Errno::EHOSTDOWN => e
|
74
|
+
raise FetchError.new(e.message, uri)
|
75
75
|
end
|
76
76
|
|
77
|
-
|
78
|
-
|
79
|
-
|
77
|
+
def configure_connection_for_https(connection)
|
78
|
+
require 'net/https'
|
79
|
+
connection.use_ssl = true
|
80
|
+
connection.verify_mode =
|
81
|
+
Gem.configuration.ssl_verify_mode || OpenSSL::SSL::VERIFY_PEER
|
82
|
+
store = OpenSSL::X509::Store.new
|
83
|
+
|
84
|
+
if Gem.configuration.ssl_client_cert
|
85
|
+
pem = File.read(Gem.configuration.ssl_client_cert)
|
86
|
+
connection.cert = OpenSSL::X509::Certificate.new(pem)
|
87
|
+
connection.key = OpenSSL::PKey::RSA.new(pem)
|
88
|
+
else
|
89
|
+
puts "no Client Cert configured!"
|
90
|
+
if !Gem.configuration.respond_to?(:ssl_client_cert)
|
91
|
+
puts "Loaded Gem::ConfigFile does not support ssl_client_cert"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
if Gem.configuration.ssl_ca_cert
|
96
|
+
if File.directory? Gem.configuration.ssl_ca_cert
|
97
|
+
store.add_path Gem.configuration.ssl_ca_cert
|
98
|
+
else
|
99
|
+
store.add_file Gem.configuration.ssl_ca_cert
|
100
|
+
end
|
80
101
|
else
|
81
|
-
|
102
|
+
puts "no CA Cert configured!"
|
103
|
+
store.set_default_paths
|
104
|
+
add_rubygems_trusted_certs(store)
|
82
105
|
end
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
106
|
+
connection.cert_store = store
|
107
|
+
rescue LoadError => e
|
108
|
+
raise unless (e.respond_to?(:path) && e.path == 'openssl') ||
|
109
|
+
e.message =~ / -- openssl$/
|
110
|
+
|
111
|
+
raise Gem::Exception.new(
|
112
|
+
'Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources')
|
87
113
|
end
|
88
|
-
connection.cert_store = store
|
89
|
-
rescue LoadError => e
|
90
|
-
raise unless (e.respond_to?(:path) && e.path == 'openssl') ||
|
91
|
-
e.message =~ / -- openssl$/
|
92
114
|
|
93
|
-
|
94
|
-
|
95
|
-
|
115
|
+
def add_rubygems_trusted_certs(store)
|
116
|
+
pattern = File.expand_path("./ssl_certs/*.pem", File.dirname(__FILE__))
|
117
|
+
Dir.glob(pattern).each do |ssl_cert_file|
|
118
|
+
store.add_file ssl_cert_file
|
119
|
+
end
|
120
|
+
end
|
96
121
|
|
97
|
-
|
98
|
-
|
99
|
-
Dir.glob(pattern).each do |ssl_cert_file|
|
100
|
-
store.add_file ssl_cert_file
|
122
|
+
def https?(uri)
|
123
|
+
uri.scheme.downcase == 'https'
|
101
124
|
end
|
102
|
-
end
|
103
125
|
|
104
|
-
def https?(uri)
|
105
|
-
uri.scheme.downcase == 'https'
|
106
126
|
end
|
107
|
-
|
108
127
|
end
|
@@ -17,10 +17,10 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
18
|
s.require_paths = ["lib"]
|
19
19
|
|
20
|
+
# s.add_development_dependency "rubygems", ['< 2.1.0']
|
20
21
|
s.add_development_dependency "rake"
|
21
22
|
s.add_development_dependency "rspec"
|
22
23
|
s.add_development_dependency "rspec-core"
|
23
24
|
s.add_development_dependency "mime-types", '1.25' if RUBY_VERSION < "1.9"
|
24
|
-
# s.add_development_dependency "simplecov", '~> 0.7.1'
|
25
25
|
s.add_development_dependency "coveralls"
|
26
26
|
end
|
@@ -5,7 +5,7 @@ describe Gem::RemoteFetcher do
|
|
5
5
|
|
6
6
|
def create_fetcher()
|
7
7
|
fetcher = subject
|
8
|
-
fetcher
|
8
|
+
return fetcher
|
9
9
|
end
|
10
10
|
|
11
11
|
describe "#https?" do
|
@@ -20,8 +20,12 @@ describe Gem::RemoteFetcher do
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
describe "#configure_connection_for_https" do
|
24
|
-
|
25
|
-
|
23
|
+
# describe "#configure_connection_for_https" do
|
24
|
+
# it "configures ssl settings on the connection" do
|
25
|
+
# fetcher = create_fetcher()
|
26
|
+
# connection = #mock Net::HTTP object
|
27
|
+
# fetcher.configure_connection_for_https(connection)
|
28
|
+
# end
|
29
|
+
# end
|
26
30
|
|
27
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubygems_ssl-client-certs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2.pre.alpha.pre.51
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Moses
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|