rubygems_ssl-client-certs 0.0.1.pre.alpha.pre.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +19 -0
- data/.travis.yml +10 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +27 -0
- data/README.md +6 -0
- data/Rakefile +12 -0
- data/lib/rubygems_plugin.rb +108 -0
- data/lib/rubygems_ssl-client-certs/version.rb +5 -0
- data/lib/rubygems_ssl-client-certs.rb +7 -0
- data/rubygems_ssl-client-certs.gemspec +23 -0
- data/spec/fixtures/gemrc +11 -0
- data/spec/gem_config_file_spec.rb +22 -0
- data/spec/gem_remote_fetcher_spec.rb +27 -0
- data/spec/spec_helper.rb +6 -0
- metadata +100 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NDUxMzRkMThkZjQ3ZWVlZjRjNDljZjhiNzA4YmNiMzRjMTYwNGM5ZQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YjAwYTUzZjQ4MGE0ZTk5MWU5NzU5ZTMwYmQ3NjVkMGNiNzcyN2QyNw==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
OGE0YThiMGJhYmVmNDhhNGUyNTJjZjZkODZiZGYwMDQ2YWEyN2Y5NTg2ZjZi
|
10
|
+
Y2E5MzM0MDZhMjAyNjE4NDVhYjhhOGI0MzE0ZjY2YjU4ZDAwYTE0M2IwMmRl
|
11
|
+
MzU4MTZhM2QyNzFkY2YwMWU5MGYwMGUyM2IwNjZhYzJlMTE4NDI=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
OWI2OTNmYTZkYmY1MDI2ODQyMjAwZTY4ZWVmOTViM2NlYmQyMmQ0NjAwMDEx
|
14
|
+
YjA4OTkxNzUyZTI1NTIwYjliZmNiZGU3NjcxMGQ4OWIzOTUyNzUwN2I3Y2Zh
|
15
|
+
NGY0NmIxY2Y1M2M2NjMwNmIwODU2Njg1YzFhNWQ1M2JiNTViOWM=
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
language: ruby
|
2
|
+
bundler_args: --no-deployment
|
3
|
+
rvm:
|
4
|
+
- 1.8.7
|
5
|
+
- 1.9.3
|
6
|
+
- 2.0.0
|
7
|
+
deploy:
|
8
|
+
provider: rubygems
|
9
|
+
api_key:
|
10
|
+
secure: H97wLo76fndF6JG5PUOe141oDQDjqri9vSXqJSjjdB5VwnPbYhwnS1mt4NANNi4UsqmqHkGRXJufNWJ2LRzz3CNX4/wFEDHLSZxu8PuHy68M9wPpOQLZwYk6sX5R47wOjsVA3Ob5/79ftndv3ipHkLGxLj56Z8XEjQ+FUzUwbiI=
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rubygems_client-certs (0.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.2.5)
|
10
|
+
rake (10.1.0)
|
11
|
+
rspec (2.14.1)
|
12
|
+
rspec-core (~> 2.14.0)
|
13
|
+
rspec-expectations (~> 2.14.0)
|
14
|
+
rspec-mocks (~> 2.14.0)
|
15
|
+
rspec-core (2.14.7)
|
16
|
+
rspec-expectations (2.14.4)
|
17
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
18
|
+
rspec-mocks (2.14.4)
|
19
|
+
|
20
|
+
PLATFORMS
|
21
|
+
ruby
|
22
|
+
|
23
|
+
DEPENDENCIES
|
24
|
+
rake
|
25
|
+
rspec
|
26
|
+
rspec-core
|
27
|
+
rubygems_client-certs!
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'rubygems/remote_fetcher'
|
2
|
+
|
3
|
+
class Gem::ConfigFile
|
4
|
+
|
5
|
+
attr_reader :ssl_client_cert
|
6
|
+
|
7
|
+
attr_reader :ssl_verify_mode
|
8
|
+
|
9
|
+
attr_reader :ssl_ca_cert
|
10
|
+
|
11
|
+
class << self
|
12
|
+
alias_method :__new__, :new
|
13
|
+
def new(*args)
|
14
|
+
config = __new__(*args)
|
15
|
+
config.set_ssl_vars
|
16
|
+
return config
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def set_ssl_vars
|
21
|
+
@ssl_verify_mode = @hash[:ssl_verify_mode] if @hash.key? :ssl_verify_mode
|
22
|
+
@ssl_ca_cert = @hash[:ssl_ca_cert] if @hash.key? :ssl_ca_cert
|
23
|
+
@ssl_ca_cert = ENV['BUNDLE_SSL_CA_CERT'] unless @ssl_ca_cert
|
24
|
+
@ssl_client_cert = @hash[:ssl_client_cert] if @hash.key? :ssl_client_cert
|
25
|
+
@ssl_client_cert = ENV['BUNDLE_SSL_CLIENT_CERT'] unless @ssl_client_cert
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
class Gem::RemoteFetcher
|
31
|
+
|
32
|
+
def connection_for(uri)
|
33
|
+
net_http_args = [uri.host, uri.port]
|
34
|
+
|
35
|
+
if @proxy_uri and not no_proxy?(uri.host) then
|
36
|
+
net_http_args += [
|
37
|
+
@proxy_uri.host,
|
38
|
+
@proxy_uri.port,
|
39
|
+
@proxy_uri.user,
|
40
|
+
@proxy_uri.password
|
41
|
+
]
|
42
|
+
end
|
43
|
+
|
44
|
+
connection_id = [Thread.current.object_id, *net_http_args].join ':'
|
45
|
+
@connections[connection_id] ||= Net::HTTP.new(*net_http_args)
|
46
|
+
connection = @connections[connection_id]
|
47
|
+
|
48
|
+
if https?(uri) and not connection.started? then
|
49
|
+
configure_connection_for_https(connection)
|
50
|
+
end
|
51
|
+
|
52
|
+
connection.start unless connection.started?
|
53
|
+
|
54
|
+
connection
|
55
|
+
rescue defined?(OpenSSL::SSL) ? OpenSSL::SSL::SSLError : Errno::EHOSTDOWN,
|
56
|
+
Errno::EHOSTDOWN => e
|
57
|
+
raise FetchError.new(e.message, uri)
|
58
|
+
end
|
59
|
+
|
60
|
+
def configure_connection_for_https(connection)
|
61
|
+
require 'net/https'
|
62
|
+
connection.use_ssl = true
|
63
|
+
connection.verify_mode =
|
64
|
+
Gem.configuration.ssl_verify_mode || OpenSSL::SSL::VERIFY_PEER
|
65
|
+
store = OpenSSL::X509::Store.new
|
66
|
+
|
67
|
+
#if Gem.configuration.ssl_client_cert
|
68
|
+
if ENV['BUNDLE_SSL_CLIENT_CERT']
|
69
|
+
pem = File.read(Gem.configuration.ssl_client_cert)
|
70
|
+
connection.cert = OpenSSL::X509::Certificate.new(pem)
|
71
|
+
connection.key = OpenSSL::PKey::RSA.new(pem)
|
72
|
+
else
|
73
|
+
puts "no Client Cert found!"
|
74
|
+
end
|
75
|
+
|
76
|
+
#if Gem.configuration.ssl_ca_cert
|
77
|
+
if ENV['BUNDLE_SSL_CA_CERT']
|
78
|
+
if File.directory? Gem.configuration.ssl_ca_cert
|
79
|
+
store.add_path Gem.configuration.ssl_ca_cert
|
80
|
+
else
|
81
|
+
store.add_file Gem.configuration.ssl_ca_cert
|
82
|
+
end
|
83
|
+
else
|
84
|
+
puts "no CA Cert found!"
|
85
|
+
store.set_default_paths
|
86
|
+
add_rubygems_trusted_certs(store)
|
87
|
+
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
|
+
|
93
|
+
raise Gem::Exception.new(
|
94
|
+
'Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources')
|
95
|
+
end
|
96
|
+
|
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
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def https?(uri)
|
105
|
+
uri.scheme.downcase == 'https'
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "rubygems_ssl-client-certs/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "rubygems_ssl-client-certs"
|
7
|
+
s.version = Rubygems::ClientCerts::VERSION
|
8
|
+
s.version = "#{s.version}-alpha-#{ENV['TRAVIS_BUILD_NUMBER']}" if ENV['TRAVIS']
|
9
|
+
s.authors = ["Aaron Moses"]
|
10
|
+
s.homepage = "https://github.com/zebardy/rubygems_ssl-client-certs"
|
11
|
+
s.licenses = ["MIT"]
|
12
|
+
s.summary = %q{Fix ssl client cert behavior in rubygems}
|
13
|
+
s.description = %q{A rubygems plugin that monkey-patches rubygems to support ssl client certs}
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
|
20
|
+
s.add_development_dependency "rake"
|
21
|
+
s.add_development_dependency "rspec"
|
22
|
+
s.add_development_dependency "rspec-core"
|
23
|
+
end
|
data/spec/fixtures/gemrc
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Gem::ConfigFile do
|
4
|
+
|
5
|
+
def gemrc_location
|
6
|
+
File.dirname(__FILE__) + '/fixtures/gemrc'
|
7
|
+
end
|
8
|
+
|
9
|
+
describe ".new" do
|
10
|
+
it "initializes ssl vars" do
|
11
|
+
config = Gem::ConfigFile.new( [ "--config-file", gemrc_location ] )
|
12
|
+
config.ssl_verify_mode.should eq("bob")
|
13
|
+
config.ssl_ca_cert.should eq("steve")
|
14
|
+
config.ssl_client_cert.should eq("dave")
|
15
|
+
end
|
16
|
+
it "original initialize is still called" do
|
17
|
+
#Test by setting the backtrace value which defaults to false
|
18
|
+
config = Gem::ConfigFile.new( [ "--backtrace" ] )
|
19
|
+
config.backtrace.should be_true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'uri'
|
3
|
+
|
4
|
+
describe Gem::RemoteFetcher do
|
5
|
+
|
6
|
+
def create_fetcher()
|
7
|
+
fetcher = subject
|
8
|
+
fetcher
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#https?" do
|
12
|
+
it "returns true when protocol is https" do
|
13
|
+
fetcher = create_fetcher()
|
14
|
+
fetcher.https?(URI("https://www.example.com")).should be_true
|
15
|
+
end
|
16
|
+
|
17
|
+
it "returns false when protocol is http" do
|
18
|
+
fetcher = create_fetcher()
|
19
|
+
fetcher.https?(URI("http://www.example.com")).should be_false
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#configure_connection_for_https" do
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rubygems_ssl-client-certs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1.pre.alpha.pre.25
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Aaron Moses
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-11-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec-core
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: A rubygems plugin that monkey-patches rubygems to support ssl client
|
56
|
+
certs
|
57
|
+
email:
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- .travis.yml
|
64
|
+
- Gemfile
|
65
|
+
- Gemfile.lock
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- lib/rubygems_plugin.rb
|
69
|
+
- lib/rubygems_ssl-client-certs.rb
|
70
|
+
- lib/rubygems_ssl-client-certs/version.rb
|
71
|
+
- rubygems_ssl-client-certs.gemspec
|
72
|
+
- spec/fixtures/gemrc
|
73
|
+
- spec/gem_config_file_spec.rb
|
74
|
+
- spec/gem_remote_fetcher_spec.rb
|
75
|
+
- spec/spec_helper.rb
|
76
|
+
homepage: https://github.com/zebardy/rubygems_ssl-client-certs
|
77
|
+
licenses:
|
78
|
+
- MIT
|
79
|
+
metadata: {}
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ! '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ! '>'
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 1.3.1
|
94
|
+
requirements: []
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 2.1.11
|
97
|
+
signing_key:
|
98
|
+
specification_version: 4
|
99
|
+
summary: Fix ssl client cert behavior in rubygems
|
100
|
+
test_files: []
|