Top Level Namespace

Defined Under Namespace

Modules: Reedb Classes: Array, BadCacheError, DaemonError, DecryptionFailedError, EncryptionError, EncryptionFailedError, FileBusyError, FileNotFoundError, FunctionNotImplementedError, InsecureUserPasswordError, MalformedSearchError, MissingEncryptionTypeError, MissingTokenError, MissingUserPasswordError, ReedbError, ReedbHandler, UUID, UnautherisedTokenError, UnknownOSError, UnknownTokenError, VaultAlreadyScopedError, VaultDoesNotExistError, VaultError, VaultExistsAtLocationError, VaultLoggerError, VaultMissingConfigurationError, VaultNotAvailableError, VaultNotScopedError, VaultWritePermissionsError, WrongUserPasswordError

Constant Summary collapse

DRES =
0xEEE
VREM =
0xFFF
VINS =
0x000

Instance Method Summary collapse

Instance Method Details

#generate_cert(years, path) ⇒ Object

TODO: Move this function into the FUCKING security package.



614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
# File 'lib/reedb/daemon_wrapper.rb', line 614

def generate_cert(years, path)
  root_key = OpenSSL::PKey::RSA.new 4096 # the CA's public/private key
  root_ca = OpenSSL::X509::Certificate.new
  root_ca.version = 2 # cf. RFC 5280 - to make it a "v3" certificate
  root_ca.serial = 1
  root_ca.subject = OpenSSL::X509::Name.parse('/DC=org/DC=ruby-lang/CN=Ruby CA')
  root_ca.issuer = root_ca.subject # root CA's are "self-signed"
  root_ca.public_key = root_key.public_key
  root_ca.not_before = Time.now
  root_ca.not_after = root_ca.not_before + years * 365 * 24 * 60 * 60 # 2 years validity

  ef = OpenSSL::X509::ExtensionFactory.new
  ef.subject_certificate = root_ca
  ef.issuer_certificate = root_ca
  root_ca.add_extension(ef.create_extension('basicConstraints', 'CA:TRUE', true))
  root_ca.add_extension(ef.create_extension('keyUsage', 'keyCertSign, cRLSign', true))
  root_ca.add_extension(ef.create_extension('subjectKeyIdentifier', 'hash', false))
  root_ca.add_extension(ef.create_extension('authorityKeyIdentifier', 'keyid:always', false))
  root_ca.sign(root_key, OpenSSL::Digest::SHA512.new)

  FileUtils::mkdir_p(path) unless File.directory?(path)

  File.open(File.join(path, Reedb::CERT_PATH), 'w+') { |file| file.write(root_ca) }
  File.open(File.join(path, Reedb::KEY_PATH), 'w+') { |file| file.write(root_key) }
end

#http_serverObject

Next up we start the HTTP server and that’s that. We’re up and running :)



641
642
643
644
645
646
647
648
649
650
651
652
# File 'lib/reedb/daemon_wrapper.rb', line 641

def http_server

  if not Reedb::Utilities::check_port(@options[:port])
    Rack::Handler::WEBrick.run(ReedbHandler.new, { :Port => @options[:port], :BindAddress => 'localhost' })
  else
    # This temporary
    puts 'The port is closed. You should do this:'
    puts '$ sudo netstat -lpn | grep 55736'
    puts '$ kill -9 <pid>'
    exit
  end
end