Sha256: 9889d0c25adc522389e439ce59eca3393cb2ee543c735885a61d1b8173c9e4f9

Contents?: true

Size: 1.23 KB

Versions: 10

Compression:

Stored size: 1.23 KB

Contents

require 'sinatra/base'
require 'webrick'
require 'webrick/https'
require 'openssl'

name = "/C=US/ST=SomeState/L=SomeCity/O=Organization/OU=Unit/CN=localhost"
ca  = OpenSSL::X509::Name.parse( name )
key = OpenSSL::PKey::RSA.new( 1024 )
crt = OpenSSL::X509::Certificate.new

crt.version = 2
crt.serial  = 1
crt.subject = ca
crt.issuer  = ca
crt.public_key = key.public_key
crt.not_before = Time.now
crt.not_after  = Time.now + 1 * 365 * 24 * 60 * 60 # 1 year

options = {
    Port:            ARGV.first.gsub( /\D/, '' ).to_i,
    SSLEnable:       true,
    SSLVerifyClient: OpenSSL::SSL::VERIFY_NONE,
    SSLCertificate:  crt,
    SSLPrivateKey:   key,
    SSLCertName:     [["CN", WEBrick::Utils::getservername]],
}

class SpiderHTTPSServer < Sinatra::Base

    get '/' do
        <<-EOHTML
            <a href="/redirect">redirect</a>
            <a href="/redirect_to_http">redirect</a>
        EOHTML
    end

    get '/redirect' do
        redirect '/stuff'
    end

    get '/stuff' do
        'Stuff'
    end

    get '/got_to_https' do
        'Stuff'
    end

    get '/redirect_to_http' do
        redirect 'http://test.com/'
    end

end

server = ::Rack::Handler::WEBrick
trap( :INT ) { server.shutdown }

server.run( SpiderHTTPSServer, options )

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
arachni-0.4.7 spec/support/servers/arachni/spider_https.rb
arachni-0.4.6 spec/support/servers/arachni/spider_https.rb
arachni-0.4.5.2 spec/support/servers/arachni/spider_https.rb
arachni-0.4.5.1 spec/support/servers/arachni/spider_https.rb
arachni-0.4.5 spec/support/servers/arachni/spider_https.rb
arachni-0.4.4 spec/support/servers/arachni/spider_https.rb
arachni-0.4.3.2 spec/support/servers/arachni/spider_https.rb
arachni-0.4.3.1 spec/support/servers/arachni/spider_https.rb
arachni-0.4.3 spec/support/servers/arachni/spider_https.rb
arachni-0.4.2 spec/servers/arachni/spider_https.rb