forked from braintree/braintree_android
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttpsd.rb
More file actions
executable file
·28 lines (24 loc) · 830 Bytes
/
Copy pathhttpsd.rb
File metadata and controls
executable file
·28 lines (24 loc) · 830 Bytes
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
#!/usr/bin/env ruby
require 'webrick'
require 'webrick/https'
require 'openssl'
private_key_file = "#{__dir__}/privateKey.key"
cert_file = "#{__dir__}/certificate.crt"
pkey = OpenSSL::PKey::RSA.new(File.read(private_key_file))
cert = OpenSSL::X509::Certificate.new(File.read(cert_file))
pid_file = ARGV[0]
s = WEBrick::HTTPServer.new(
:BindAddress => '0.0.0.0',
:Port => 9443,
:Logger => WEBrick::Log::new(nil, WEBrick::Log::ERROR),
:DocumentRoot => File.join(File.dirname(__FILE__)),
:ServerType => WEBrick::Daemon,
:SSLEnable => true,
:SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
:SSLCertificate => cert,
:SSLPrivateKey => pkey,
:SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ],
:StartCallback => proc { File.open(pid_file, "w") { |f| f.write $$.to_s }}
)
trap("INT"){ s.shutdown }
s.start