forked from SerpicoProject/Serpico
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserpico.rb
30 lines (25 loc) · 891 Bytes
/
serpico.rb
1
2
3
4
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
require "bundler/setup"
require 'webrick/https'
require 'openssl'
require 'json'
require "./server.rb"
config_options = JSON.parse(File.read('./config.json'))
## SSL Settings
ssl_certificate = config_options["ssl_certificate"]
ssl_key = config_options["ssl_key"]
use_ssl = config_options["use_ssl"]
port = config_options["port"]
bind_address = config_options["bind_address"]
server_options = {
:Port => port,
:BindAddress => bind_address
}
if (use_ssl) then
certificate_content = File.open(ssl_certificate).read
key_content = File.open(ssl_key).read
server_options[:SSLEnable] = true
server_options[:SSLCertificate] = OpenSSL::X509::Certificate.new(certificate_content)
server_options[:SSLPrivateKey] = OpenSSL::PKey::RSA.new(key_content)
server_options[:SSLVerifyClient] = OpenSSL::SSL::VERIFY_NONE
end
Rack::Handler::WEBrick.run Server, server_options