Module: Watobo::CertStore
- Defined in:
- lib/watobo/core/cert_store.rb
Overview
:nodoc: all
Class Method Summary collapse
Class Method Details
.acquire_ssl_ctx(target, cn) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/watobo/core/cert_store.rb', line 5 def self.acquire_ssl_ctx(target, cn) ctx = OpenSSL::SSL::SSLContext.new() unless @fake_certs.has_key? target cert_prefs = { :hostname => cn, :type => 'server', :user => 'watobo', :email => 'watobo@localhost', } cert_file, key_file = Watobo::CA.create_cert cert_prefs fake_cert = OpenSSL::X509::Certificate.new(File.read(cert_file)) fake_key = OpenSSL::PKey::RSA.new(File.read(key_file)) #ctx = OpenSSL::SSL::SSLContext.new('SSLv23_server') @fake_certs[target] = { :cert => fake_cert, :key => fake_key } end fc = @fake_certs[target] ctx.cert = fc[:cert] ctx.key = fc[:key] ctx.tmp_dh_callback = proc { |*args| Watobo::CA.dh_key } ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE ctx.timeout = 10 return ctx end |