Module: OpenSSL::Win::Root

Defined in:
lib/openssl/win/root/version.rb,
lib/openssl/win/root.rb

Defined Under Namespace

Modules: Crypt

Constant Summary collapse

VERSION =
"0.9.1"
On =
Gem.win_platform?

Class Method Summary collapse

Class Method Details

.go!Object



77
78
79
80
81
# File 'lib/openssl/win/root.rb', line 77

def self.go!
  t = Thread.new{ save }
  at_exit{t.join}
  inject
end

.injectObject



72
73
74
75
# File 'lib/openssl/win/root.rb', line 72

def self.inject
  OpenSSL::SSL::SSLContext::DEFAULT_CERT_STORE.add_path path
  path
end

.pathObject



63
64
65
66
67
68
69
70
# File 'lib/openssl/win/root.rb', line 63

def self.path
  return @path if @path
  x = File.expand_path '..', __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 = path) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/openssl/win/root.rb', line 44

def self.save(path=path)
  my={}
  Crypt.each do |crt|
    File.open File.join(path, name='%08x.0'%crt.subject.hash), 'w' do |f|
      my[name]=1
      f.puts "Subject: \#{crt.subject}\nValid:   \#{crt.not_before} - \#{crt.not_after}\nSaved:   \#{self} v\#{VERSION} @\#{Time.now}\n\#{crt.to_pem}\n\#{crt.to_text}\n      EOT\n    end\n  end\n  Dir.glob File.join path, '*' do |f|\n    File.unlink f unless my[File.basename f]\n  end\nend\n"