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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjkwMWM2YjI2ZDI0Y2JkNDYxZDk4OTAxNDQ3Yzg5ZjVmMjk4NzZmNg==
4
+ ZjI1NTFmNDE5NjU5YmE5ZDU0N2ViNmM1YjNmM2Y2OGYxOWEzNGE0Yw==
5
5
  data.tar.gz: !binary |-
6
- Y2U2OTA0NjgxM2IxMTY0YmUzOGI5Njc0NzExNTcwOTdhNzRlZWI4MQ==
6
+ NGE3NTM2NTJmNjUxYjRjZDk5N2I1OWZlYzZkN2NlZjcxYTFjNDViOQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZDFmYjllNWQyNWE2YWU5Y2IzY2I3MTkzNTk0MGU4ZDQwNjM3NGVkY2M2YzQ2
10
- NmZkZjBiN2FhNzAwOTczYjdiNDcxMWMzOGViZmU0ZTVlOTM3ZWQxMDllMDBh
11
- ZGVhNjIwZjI1OWM5NjU1NmIyNThkZWIwY2ZkMTQ5MzUzMDc1MDA=
9
+ MWYyZGQ2ZDM0OTc5MTJiN2VjMjI5OTYxZGIxN2MzMGJlZmU1M2FjOTMwOTRh
10
+ M2RkMTU4YjIwMDQ0ZjNjMTE5MmM2ZDJhZmQxMzdlOTAzNzg0ZDMxMWFkMzI2
11
+ NTE0YmJmOGRiODRjMDY1ZTNkODgxMzg1Y2QxOWUxNzk5MjdhNGM=
12
12
  data.tar.gz: !binary |-
13
- ZmZkZmFlODYwMTkzYmUwMDE1NGYyNzQzMzExNTBiYzk0NzMwZjUxMzM2NDg5
14
- YzczMjZmMzRhODZkMjhjZTI2MmEyYjIxZmFiOGFmZWVkNDhjYzQ3YzNmYTAx
15
- YTUxOGE4YzBiMGVkZWYyNTRjMzg2ZTFlNWI1ZTllYWIyN2I0ZTE=
13
+ NzI2NWM2ODg3ODVlNDlkZDU2MWFlZWFjMmMzZTk0NjY1Zjk3OTE0NDgxNWYw
14
+ ODE5M2IwODBkYTg0NzkxYTNiYTY2YTViMzk2ODg4NzRmZWFiNTI4ZmY1MDI2
15
+ MzVmMDMzYzU4MmE4YTU4MjQxMWY5OGE0MWEzM2Q4OTQxMmVhMDM=
data/.gitignore CHANGED
@@ -3,6 +3,7 @@
3
3
  *.swp
4
4
  .bundle
5
5
  .config
6
+ .rvmrc
6
7
  Gemfile.lock
7
8
  coverage
8
9
  InstalledFiles
data/.travis.yml CHANGED
@@ -1,5 +1,8 @@
1
1
  language: ruby
2
2
  bundler_args: --no-deployment
3
+ before_install:
4
+ #- gem update --system 2.0.14
5
+ - gem install 'rubygems_allow-pre-releases'
3
6
  rvm:
4
7
  - 1.8.7
5
8
  - 1.9.3
@@ -1,108 +1,127 @@
1
1
  require 'rubygems/remote_fetcher'
2
2
 
3
- class Gem::ConfigFile
3
+ $stderr.puts "rubygems ssl client certs plugin loading"
4
4
 
5
- attr_reader :ssl_client_cert
5
+ if Gem::Version.new(Gem::VERSION) < Gem::Version.new('2.1.0') then
6
6
 
7
- attr_reader :ssl_verify_mode
7
+ class Gem::Version
8
8
 
9
- attr_reader :ssl_ca_cert
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
- end
15
+ class Gem::ConfigFile
31
16
 
32
- class Gem::RemoteFetcher
17
+ attr_reader :ssl_client_cert
33
18
 
34
- def connection_for(uri)
35
- net_http_args = [uri.host, uri.port]
19
+ attr_reader :ssl_verify_mode
36
20
 
37
- if @proxy_uri and not no_proxy?(uri.host) then
38
- net_http_args += [
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
- if https?(uri) and not connection.started? then
51
- configure_connection_for_https(connection)
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
- connection.start unless connection.started?
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
- def configure_connection_for_https(connection)
63
- require 'net/https'
64
- connection.use_ssl = true
65
- connection.verify_mode =
66
- Gem.configuration.ssl_verify_mode || OpenSSL::SSL::VERIFY_PEER
67
- store = OpenSSL::X509::Store.new
68
-
69
- if Gem.configuration.ssl_client_cert
70
- pem = File.read(Gem.configuration.ssl_client_cert)
71
- connection.cert = OpenSSL::X509::Certificate.new(pem)
72
- connection.key = OpenSSL::PKey::RSA.new(pem)
73
- else
74
- puts "no Client Cert configured!"
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
- if Gem.configuration.ssl_ca_cert
78
- if File.directory? Gem.configuration.ssl_ca_cert
79
- store.add_path Gem.configuration.ssl_ca_cert
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
- store.add_file Gem.configuration.ssl_ca_cert
102
+ puts "no CA Cert configured!"
103
+ store.set_default_paths
104
+ add_rubygems_trusted_certs(store)
82
105
  end
83
- else
84
- puts "no CA Cert configured!"
85
- store.set_default_paths
86
- add_rubygems_trusted_certs(store)
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
- raise Gem::Exception.new(
94
- 'Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources')
95
- end
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
- def add_rubygems_trusted_certs(store)
98
- pattern = File.expand_path("./ssl_certs/*.pem", File.dirname(__FILE__))
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
@@ -1,5 +1,5 @@
1
1
  module Rubygems
2
2
  module ClientCerts
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  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
- end
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.1.pre.alpha.pre.35
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-04 00:00:00.000000000 Z
11
+ date: 2013-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake