openssl-win-root 0.9.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +18 -18
- data/LICENSE.txt +22 -22
- data/README.md +8 -0
- data/Rakefile +1 -1
- data/lib/openssl/win/root.rb +21 -15
- data/lib/openssl/win/root/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65329bdf4434c32ea76fcfb683411b35620f38cd
|
4
|
+
data.tar.gz: d7d4e6a1d7a7822a96e95f5e0efbcb05153f450c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6a7db7583537aba404f7f0d8f9f92f6332aac90373269bf7170c9161a396f589e2187ed3f5319b3c508ad3c9e72ee9629e3677600a03ab44810bb44d93ba4ec
|
7
|
+
data.tar.gz: 0389b19fa2df8a3c02ce68516841ac36ad050e404736ef36d400b1c9145b3ccb9ebd00e45dcfec87f922f7345e6ccd54f8168833c86ddaa5232e5e648b912828
|
data/.gitignore
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
*.gem
|
2
|
-
*.rbc
|
3
|
-
.bundle
|
4
|
-
.config
|
5
|
-
.yardoc
|
6
|
-
Gemfile.lock
|
7
|
-
InstalledFiles
|
8
|
-
_yardoc
|
9
|
-
coverage
|
10
|
-
doc/
|
11
|
-
lib/bundler/man
|
12
|
-
pkg
|
13
|
-
rdoc
|
14
|
-
spec/reports
|
15
|
-
test/tmp
|
16
|
-
test/version_tmp
|
17
|
-
tmp
|
18
|
-
pem
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
pem
|
data/LICENSE.txt
CHANGED
@@ -1,22 +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.
|
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
CHANGED
@@ -52,6 +52,14 @@ require 'net/http'
|
|
52
52
|
Net::HTTP.get(URI 'https://ya.ru').length
|
53
53
|
```
|
54
54
|
|
55
|
+
You can use fetched certificates in non-Ruby projects by setting
|
56
|
+
environment variable `SSL_CERT_DIR` to result of `OpenSSL::Win::Root.path`
|
57
|
+
or via `-CApath` argument of `openssl` command.
|
58
|
+
|
59
|
+
## See also
|
60
|
+
|
61
|
+
* [Rufus::Lua::Win](https://github.com/ukoloff/rufus-lua-win)
|
62
|
+
|
55
63
|
## Credits
|
56
64
|
|
57
65
|
* [Ruby](https://www.ruby-lang.org/)
|
data/Rakefile
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/openssl/win/root.rb
CHANGED
@@ -8,6 +8,7 @@ module OpenSSL::Win::Root
|
|
8
8
|
|
9
9
|
On = Gem.win_platform?
|
10
10
|
|
11
|
+
# Based on Puppet::Util::Windows::RootCerts
|
11
12
|
module Crypt
|
12
13
|
extend FFI::Library
|
13
14
|
ffi_lib 'crypt32'
|
@@ -29,7 +30,6 @@ module OpenSSL::Win::Root
|
|
29
30
|
end
|
30
31
|
end
|
31
32
|
|
32
|
-
# Based on Puppet::Util::Windows::RootCerts
|
33
33
|
def self.each
|
34
34
|
store = open nil, 'ROOT'
|
35
35
|
begin
|
@@ -41,36 +41,41 @@ module OpenSSL::Win::Root
|
|
41
41
|
end
|
42
42
|
end if On
|
43
43
|
|
44
|
+
# Path where certificates will be
|
45
|
+
def self.path
|
46
|
+
return @path if @path
|
47
|
+
x = File.expand_path '..', __FILE__
|
48
|
+
x = File.dirname x until File.exists? File.join x, 'Gemfile'
|
49
|
+
x = File.join x, 'pem'
|
50
|
+
FileUtils.mkdir_p x
|
51
|
+
@path = x
|
52
|
+
end
|
53
|
+
|
54
|
+
# Almost c_rehash
|
44
55
|
def self.save(path=path)
|
45
56
|
names={}
|
46
57
|
hashes={}
|
47
58
|
Crypt.each do |crt|
|
48
|
-
hash=crt.subject.hash
|
49
|
-
|
50
|
-
|
59
|
+
peers=hashes[hash=crt.subject.hash]||={}
|
60
|
+
id=OpenSSL::Digest::SHA1.new.digest crt.to_der
|
61
|
+
next if peers[id]
|
62
|
+
names[name='%08x.%i' % [hash, peers.length]]=1
|
63
|
+
peers[id]=1
|
51
64
|
File.open File.join(path, name), 'w' do |f|
|
52
65
|
f.puts <<-EOT
|
53
66
|
Subject: #{crt.subject}
|
54
67
|
Valid: #{crt.not_before} - #{crt.not_after}
|
55
|
-
Saved: #{self} v#{VERSION}
|
68
|
+
Saved: #{Time.now} by #{self} v#{VERSION}
|
56
69
|
#{crt.to_pem}
|
57
70
|
EOT
|
58
71
|
end
|
59
72
|
end
|
60
73
|
Dir.glob File.join path, '*' do |f|
|
61
|
-
File.unlink f unless names[File.basename f]
|
74
|
+
File.unlink f rescue nil unless names[File.basename f]
|
62
75
|
end
|
63
76
|
end
|
64
77
|
|
65
|
-
|
66
|
-
return @path if @path
|
67
|
-
x = File.expand_path '..', __FILE__
|
68
|
-
x = File.dirname x until File.exists? File.join x, 'Gemfile'
|
69
|
-
x = File.join x, 'pem'
|
70
|
-
FileUtils.mkdir_p x
|
71
|
-
@path = x
|
72
|
-
end
|
73
|
-
|
78
|
+
# Instruct OpenSSL to use fetched certificates
|
74
79
|
def self.inject
|
75
80
|
OpenSSL::SSL::SSLContext::DEFAULT_CERT_STORE.add_path path
|
76
81
|
path
|
@@ -78,6 +83,7 @@ Saved: #{self} v#{VERSION} @#{Time.now}
|
|
78
83
|
|
79
84
|
def self.go!
|
80
85
|
t = Thread.new{ save }
|
86
|
+
t.abort_on_exception=true
|
81
87
|
at_exit{t.join}
|
82
88
|
inject
|
83
89
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openssl-win-root
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stas Ukolov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -91,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
91
|
version: '0'
|
92
92
|
requirements: []
|
93
93
|
rubyforge_project:
|
94
|
-
rubygems_version: 2.
|
94
|
+
rubygems_version: 2.4.6
|
95
95
|
signing_key:
|
96
96
|
specification_version: 4
|
97
97
|
summary: ''
|