Module: OpenSSL::Win::Root
- Defined in:
- lib/openssl/win/root/version.rb,
lib/openssl/win/root.rb
Defined Under Namespace
Modules: Crypt Classes: CRehash
Constant Summary collapse
- VERSION =
"1.1.1"- On =
Gem.win_platform?
Class Method Summary collapse
- .go! ⇒ Object
-
.inject ⇒ Object
Instruct OpenSSL to use fetched certificates.
-
.path ⇒ Object
Path where certificates will be.
-
.save(path = self.path) ⇒ Object
Almost c_rehash.
Class Method Details
.go! ⇒ Object
103 104 105 106 107 108 |
# File 'lib/openssl/win/root.rb', line 103 def self.go! t = Thread.new{ save } t.abort_on_exception=true at_exit{t.join} inject end |
.inject ⇒ Object
Instruct OpenSSL to use fetched certificates
98 99 100 101 |
# File 'lib/openssl/win/root.rb', line 98 def self.inject OpenSSL::SSL::SSLContext::DEFAULT_CERT_STORE.add_path path ENV["SSL_CERT_DIR"] = path end |
.path ⇒ Object
Path where certificates will be
44 45 46 47 48 49 50 51 |
# File 'lib/openssl/win/root.rb', line 44 def self.path return @path if @path x = File. '..', __FILE__ x = File.dirname x until File.exists? File.join x, 'Gemfile' x = File.join x, 'pem' FileUtils.mkdir_p x @path = x end |
.save(path = self.path) ⇒ Object
Almost c_rehash
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/openssl/win/root.rb', line 75 def self.save(path=self.path) cr = CRehash.new Crypt.each do |crt| next unless cr.unique OpenSSL::Digest::SHA1.new.digest crt.to_der name = File.join path, cr.name(crt.subject.hash) File.open name, 'w' do |f| f.puts "Subject: \#{crt.subject}\nValid: \#{crt.not_before} - \#{crt.not_after}\nSaved: \#{Time.now} by \#{self} v\#{VERSION}\n\#{crt.to_pem}\n EOT\n end\n link = File.join path, cr.name(crt.subject.hash_old)\n FileUtils.ln name, link, force: true\n end\n Dir.glob File.join path, '*' do |f|\n File.unlink f rescue nil unless cr.names[File.basename f]\n end\nend\n" |