openssl-win-root 0.9.2 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a9dce0464f5e87e087cbb19735ec63627847c5b4
4
- data.tar.gz: b8ea6e6cdc1917d355e5798134d6da552dd9f441
3
+ metadata.gz: 65329bdf4434c32ea76fcfb683411b35620f38cd
4
+ data.tar.gz: d7d4e6a1d7a7822a96e95f5e0efbcb05153f450c
5
5
  SHA512:
6
- metadata.gz: b77749d09eccb1fe0e6beac76620301805a46186d75262964d268e6ed08b03a85d9276e765ff72663473628d6019857ef27d089dac4e48c1e3fb416fde1c3242
7
- data.tar.gz: 07f4f007c27bcf100a4cdfb488a8080b1eb12701a2203af73a0727644ac4555d1a26b8903af316d9923ba933a78e0fe0f2342247448abd39b0a2dca72bd0790c
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
@@ -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"
@@ -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
- names[name='%08x.%i' % [hash, hashes[hash]||=0]]=1
50
- hashes[hash]+=1
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} @#{Time.now}
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
- def self.path
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
@@ -1,7 +1,7 @@
1
1
  module OpenSSL
2
2
  module Win
3
3
  module Root
4
- VERSION = "0.9.2"
4
+ VERSION = "1.0.0"
5
5
  end
6
6
  end
7
7
  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.9.2
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-13 00:00:00.000000000 Z
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.0.14
94
+ rubygems_version: 2.4.6
95
95
  signing_key:
96
96
  specification_version: 4
97
97
  summary: ''