Beispiel #1
0
# -*- Mode: Python -*-

# demo an https server using OpenSSL.

import coro
import coro.http
import coro.backdoor
from coro.ssl import openssl

ctx = coro.ssl.new_ctx (
    cert = openssl.x509 (open('../cert/server.crt').read()),
    key  = openssl.pkey (open('../cert/server.key').read(), private=True),
    )

server = coro.http.openssl_server (ctx)
server.push_handler (coro.http.handlers.coro_status_handler())
server.push_handler (coro.http.handlers.favicon_handler())
coro.spawn (server.start, ('0.0.0.0', 9443))
coro.spawn (coro.backdoor.serve, unix_path='/tmp/https.bd')
coro.event_loop (30.0)
Beispiel #2
0
 def make_socket (self):
     from coro.ssl import openssl, sock, new_ctx
     ctx = new_ctx (proto='tlsv1')
     ctx.use_cert (openssl.x509 (open ('server.crt').read()))
     ctx.use_key (openssl.pkey (open ('server.key').read(), '', True))
     return sock (ctx, verify=self.verify_tls)
Beispiel #3
0
 def make_socket(self):
     from coro.ssl import openssl, sock, new_ctx
     ctx = new_ctx(proto='tlsv1')
     ctx.use_cert(openssl.x509(open('server.crt').read()))
     ctx.use_key(openssl.pkey(open('server.key').read(), '', True))
     return sock(ctx, verify=self.verify_tls)
Beispiel #4
0
# -*- Mode: Python -*-

# demo an https server using OpenSSL.

import coro
import coro.http
import coro.backdoor
from coro.ssl import openssl

ctx = coro.ssl.new_ctx(
    cert=openssl.x509(open('../cert/server.crt').read()),
    key=openssl.pkey(open('../cert/server.key').read(), private=True),
)

server = coro.http.openssl_server(ctx)
server.push_handler(coro.http.handlers.coro_status_handler())
server.push_handler(coro.http.handlers.favicon_handler())
coro.spawn(server.start, ('0.0.0.0', 9443))
coro.spawn(coro.backdoor.serve, unix_path='/tmp/https.bd')
coro.event_loop(30.0)
Beispiel #5
0
# -*- Mode: Python -*-

import coro
from coro.ssl import openssl
import coro.ssl
import coro.backdoor

W = coro.write_stderr

ctx = openssl.ssl_ctx()
ctx.use_cert (openssl.x509 (open ('../../http/cert/server.crt').read()))
ctx.use_key (openssl.pkey (open ('../../http/cert/server.key').read(), '', True))
ctx.set_ciphers ('RC4-SHA:RC4-MD5:ALL')
# ctx.set_tmp_dh (openssl.dh_param (open ('../../http/cert/dh_param_1024.pem').read()))
# ctx.set_next_protos (['spdy/2', 'http/1.1'])

def session (conn, addr):
    conn.ssl.set_fd (conn.fd)
    try:
        print 'conn=', conn, conn.__class__
        while 1:
            block = conn.recv (1000)
            if not block:
                break
            else:
                conn.send (block)
    finally:
        coro.sleep_relative (1000)
        W ('why for I exit?\n')

all_conns = []