openssl-win-root 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/FarMenu.ini +12 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +59 -0
- data/Rakefile +1 -0
- data/ext/Rakefile +3 -0
- data/ext/mkrf_conf.rb +0 -0
- data/lib/openssl/win/root.rb +100 -0
- data/lib/openssl/win/root/version.rb +7 -0
- data/openssl-win-root.gemspec +27 -0
- metadata +98 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c8efedecb76d722740ca0373f393abcd59b74589
|
4
|
+
data.tar.gz: a30d32f28d6089cb2c6bfa4594c3b11c39c1832c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a074031098476c9ebc8bad468836bb3b4f88d41a9ceb30fec09b6f5396e30da89f77ab5a7736e4b0df710d5ca968930a2a20d30fa6dd1289a09633e4282a8ac5
|
7
|
+
data.tar.gz: 52088461747c1a7d66e7efc92ac2ab509c3d721556db1a187334c1da99124de22be58781bd93c74252757e7d16bb558dc30173279920d0d5b501554d91dcde14
|
data/.gitignore
ADDED
data/FarMenu.ini
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Stas Ukolov
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# OpenSSL::Win::Root
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/openssl-win-root.svg)](http://badge.fury.io/rb/openssl-win-root)
|
4
|
+
|
5
|
+
Fetch Root CA certificates from Windows system store.
|
6
|
+
|
7
|
+
## Abstract
|
8
|
+
|
9
|
+
Default installation of Ruby on Microsoft Windows provides no root certificates at all.
|
10
|
+
Secure connections are simply impossible.
|
11
|
+
|
12
|
+
Recommended fix is to load http://curl.haxx.se/ca/cacert.pem and set SSL_CERT_FILE environment variable.
|
13
|
+
|
14
|
+
But Windows has its own certificate store. This gem just access it, fetch trusted root certificates
|
15
|
+
and feed them to Ruby's OpenSSL.
|
16
|
+
|
17
|
+
So, if you installed some certificates or your company certificate is installed by Group Policy,
|
18
|
+
these certificates will be available to your Ruby program. In addition, no network access is required.
|
19
|
+
|
20
|
+
Under other OSes this gem does nothing.
|
21
|
+
|
22
|
+
## Installation
|
23
|
+
|
24
|
+
Add this line to your application's Gemfile:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
gem 'openssl-win-root' if Gem.win_platform?
|
28
|
+
```
|
29
|
+
|
30
|
+
And then execute:
|
31
|
+
|
32
|
+
```sh
|
33
|
+
$ bundle
|
34
|
+
```
|
35
|
+
|
36
|
+
Or install it yourself as:
|
37
|
+
|
38
|
+
```sh
|
39
|
+
$ gem install openssl-win-root
|
40
|
+
```
|
41
|
+
|
42
|
+
## Usage
|
43
|
+
|
44
|
+
Just `require 'openssl/win/root'`
|
45
|
+
|
46
|
+
If your project uses `Bundler.require` (eg. Ruby on Rails) then just do nothing!
|
47
|
+
|
48
|
+
To test whether SSL works (or not):
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
require 'net/http'
|
52
|
+
Net::HTTP.get(URI 'https://ya.ru').length
|
53
|
+
```
|
54
|
+
|
55
|
+
## Credits
|
56
|
+
|
57
|
+
* [Ruby](https://www.ruby-lang.org/)
|
58
|
+
* [OpenSSL](https://www.openssl.org/)
|
59
|
+
* [FFI](https://github.com/ffi/ffi)
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/ext/Rakefile
ADDED
data/ext/mkrf_conf.rb
ADDED
File without changes
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'ffi'
|
2
|
+
require 'openssl'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
require_relative "root/version"
|
6
|
+
|
7
|
+
module OpenSSL::Win::Root
|
8
|
+
|
9
|
+
On = Gem.win_platform?
|
10
|
+
|
11
|
+
module Crypt
|
12
|
+
extend FFI::Library
|
13
|
+
ffi_lib 'crypt32'
|
14
|
+
ffi_convention :stdcall
|
15
|
+
|
16
|
+
attach_function :open, :CertOpenSystemStoreA, [:pointer, :string], :pointer
|
17
|
+
attach_function :close, :CertCloseStore, [:pointer, :uint], :int
|
18
|
+
attach_function :enum, :CertEnumCertificatesInStore, [:pointer, :pointer], :pointer
|
19
|
+
|
20
|
+
class Ctx < FFI::Struct
|
21
|
+
layout :dwCertEncodingType, :uint,
|
22
|
+
:pbCertEncoded, :pointer,
|
23
|
+
:cbCertEncoded, :uint,
|
24
|
+
:pCertInfo, :pointer,
|
25
|
+
:hCertStore, :pointer
|
26
|
+
|
27
|
+
def crt
|
28
|
+
OpenSSL::X509::Certificate.new self[:pbCertEncoded].read_string self[:cbCertEncoded]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Based on Puppet::Util::Windows::RootCerts
|
33
|
+
def self.each
|
34
|
+
store = open nil, 'ROOT'
|
35
|
+
begin
|
36
|
+
ctx = nil
|
37
|
+
yield Ctx.new(ctx).crt until (ctx = enum store, ctx).null?
|
38
|
+
ensure
|
39
|
+
close store, 0
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end if On
|
43
|
+
|
44
|
+
def self.save(f=STDOUT)
|
45
|
+
f.puts <<-EOT
|
46
|
+
#
|
47
|
+
# Generated by #{self} v#{VERSION} @#{Time.now}
|
48
|
+
#
|
49
|
+
|
50
|
+
EOT
|
51
|
+
Crypt.each do |crt|
|
52
|
+
f.puts <<-EOT
|
53
|
+
Subject: #{crt.subject}
|
54
|
+
Valid: #{crt.not_before} - #{crt.not_after}
|
55
|
+
#{crt.to_pem}
|
56
|
+
EOT
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.path
|
61
|
+
return @path if @path
|
62
|
+
x = File.expand_path '..', __FILE__
|
63
|
+
x = File.dirname x until File.exists? File.join x, 'Gemfile'
|
64
|
+
x = File.join x, 'pem'
|
65
|
+
FileUtils.mkdir_p x
|
66
|
+
@path = File.join x, 'cacert.pem'
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.tmpnam
|
70
|
+
File.join File.dirname(path), "#{rand.to_s.gsub /\D+/, ''}.pem"
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.update
|
74
|
+
tmp = tmpnam
|
75
|
+
begin
|
76
|
+
File.open(tmp, 'w'){|f| save f}
|
77
|
+
FileUtils.mv tmp, path, force: true
|
78
|
+
inject
|
79
|
+
ensure
|
80
|
+
File.unlink tmp rescue nil
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.inject
|
85
|
+
return unless File.exists? path
|
86
|
+
return if @inject
|
87
|
+
OpenSSL::SSL::SSLContext::DEFAULT_CERT_STORE.add_file path
|
88
|
+
@inject = true
|
89
|
+
path
|
90
|
+
end
|
91
|
+
|
92
|
+
def self.go!
|
93
|
+
t = Thread.new{ update }
|
94
|
+
at_exit{t.join}
|
95
|
+
inject
|
96
|
+
end
|
97
|
+
|
98
|
+
go! if On
|
99
|
+
|
100
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'openssl/win/root/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "openssl-win-root"
|
8
|
+
spec.version = OpenSSL::Win::Root::VERSION
|
9
|
+
spec.authors = ["Stas Ukolov"]
|
10
|
+
spec.email = ["ukoloff@gmail.com"]
|
11
|
+
spec.description = 'Fetch Root CA certificates from Windows system store'
|
12
|
+
spec.summary = ''
|
13
|
+
spec.homepage = "https://github.com/ukoloff/openssl-win-root"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.extensions = ['ext/mkrf_conf.rb']
|
22
|
+
|
23
|
+
spec.add_dependency "ffi"
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
26
|
+
spec.add_development_dependency "rake"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: openssl-win-root
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Stas Ukolov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ffi
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
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: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
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: Fetch Root CA certificates from Windows system store
|
56
|
+
email:
|
57
|
+
- ukoloff@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions:
|
60
|
+
- ext/mkrf_conf.rb
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- .gitignore
|
64
|
+
- FarMenu.ini
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- ext/Rakefile
|
70
|
+
- ext/mkrf_conf.rb
|
71
|
+
- lib/openssl/win/root.rb
|
72
|
+
- lib/openssl/win/root/version.rb
|
73
|
+
- openssl-win-root.gemspec
|
74
|
+
homepage: https://github.com/ukoloff/openssl-win-root
|
75
|
+
licenses:
|
76
|
+
- MIT
|
77
|
+
metadata: {}
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 2.4.6
|
95
|
+
signing_key:
|
96
|
+
specification_version: 4
|
97
|
+
summary: ''
|
98
|
+
test_files: []
|