示例#1
0
文件: server.py 项目: tiran/custodia
    def __init__(self, server_address, handler_class, config,
                 bind_and_activate=True):
        # pylint: disable=super-init-not-called, non-parent-init-called
        # Init just BaseServer, TCPServer creates a socket.
        BaseServer.__init__(self, server_address, handler_class)

        if isinstance(server_address, socket.socket):
            # It's a bound and activates socket from systemd.
            self.socket = server_address
            bind_and_activate = False
        else:
            self.socket = socket.socket(self.address_family,
                                        self.socket_type)

        # copied from TCPServer
        if bind_and_activate:
            try:
                self.server_bind()
                self.server_activate()
            except:
                self.server_close()
                raise

        if self.socket.family == socket.AF_UNIX:
            self.socket_file = self.socket.getsockname()

        if 'consumers' not in config:
            raise ValueError('Configuration does not provide any consumer')
        self.config = config
        if 'server_string' in self.config:
            self.server_string = self.config['server_string']
        self.auditlog = log.auditlog
示例#2
0
 	def __init__(self, server_address, HandlerClass, cmd=None, env_term=None, ssl_enabled=True, ssl_cert=None, www_dir='www'):
  		BaseServer.__init__(self, server_address, HandlerClass)
		# Setup SSL
		if ssl_enabled:
			try:
				ctx = SSL.Context(SSL.SSLv23_METHOD)
#				ctx.set_options(SSL.OP_NO_SSLv2)
				ctx.use_privatekey_file(ssl_cert)
				ctx.use_certificate_chain_file(ssl_cert)
				# Demand a certificate
#				ctx.set_verify(SSL.VERIFY_PEER|SSL.VERIFY_FAIL_IF_NO_PEER_CERT,
#					verify_cb)
#				ctx.load_verify_locations(os.path.join(dir, 'CA.cert'))
			except SSL.Error:
				self.socket = None
				return
		# Setup webshell multiplex
		self.webshell_files = {}
		for i in ['css', 'html', 'js', 'gif', 'jpg', 'png']:
			for j in glob.glob(www_dir + '/*.%s' % i):
				self.webshell_files[os.path.basename(j)] = file(j).read()
		self.webshell_mime = mimetypes.types_map.copy()
		self.webshell_multiplex = Multiplex(cmd, env_term)
		# Open socket
		self.socket = socket.socket(self.address_family, self.socket_type)
		if ssl_enabled:
			self.socket = SSL.Connection(ctx, self.socket)
		self.server_bind()
		self.server_activate()
示例#3
0
    def __init__(self,
                 server_address,
                 handler_class,
                 config,
                 bind_and_activate=True):
        # pylint: disable=super-init-not-called, non-parent-init-called
        # Init just BaseServer, TCPServer creates a socket.
        BaseServer.__init__(self, server_address, handler_class)

        if isinstance(server_address, socket.socket):
            # It's a bound and activates socket from systemd.
            self.socket = server_address
            bind_and_activate = False
        else:
            self.socket = socket.socket(self.address_family, self.socket_type)

        # copied from TCPServer
        if bind_and_activate:
            try:
                self.server_bind()
                self.server_activate()
            except:
                self.server_close()
                raise

        if self.socket.family == socket.AF_UNIX:
            self.socket_file = self.socket.getsockname()

        if 'consumers' not in config:
            raise ValueError('Configuration does not provide any consumer')
        self.config = config
        if 'server_string' in self.config:
            self.server_string = self.config['server_string']
        self.auditlog = log.auditlog
示例#4
0
文件: ssl.py 项目: AnatomicJC/mmc
 def __init__(self, server_address, HandlerClass, config):
     BaseServer.__init__(self, server_address, HandlerClass)
     ctx = makeSSLContext(config.verifypeer, config.cacert, config.localcert, self.sslReject)
     self.socket = SSL.Connection(ctx, socket.socket(self.address_family,
                                                     self.socket_type))
     self.server_bind()
     self.server_activate()
示例#5
0
 def __init__(self, server_address, HandlerClass, config):
     BaseServer.__init__(self, server_address, HandlerClass)
     ctx = makeSSLContext(config.verifypeer, config.cacert, config.localcert, self.sslReject)
     self.socket = SSL.Connection(ctx, socket.socket(self.address_family,
                                                     self.socket_type))
     self.server_bind()
     self.server_activate()
示例#6
0
文件: hgfserver.py 项目: hgfgood/note
 def __init__(self, server_address, HandlerClass):
     BaseServer.__init__(self, server_address, HandlerClass)
     ctx = SSL.Context(SSL.SSLv23_METHOD)        #定义一个ssl连接,ssl所采用的版本
     ctx.use_privatekey(privatekey)
     ctx.use_certificate(certificate)
     self.socket = SSL.Connection(ctx, socket.socket(self.address_family, self.socket_type))     #使用给定的OpenSSL.SSL.Content和Socket创建连接对象
     self.server_bind()
     self.server_activate()
示例#7
0
 def __init__(self, server_address, HandlerClass):
     BaseServer.__init__(self, server_address, HandlerClass)
     ctx = SSL.Context(SSL.SSLv23_METHOD)
     ctx.use_privatekey_file(privatekey)
     ctx.use_certificate_file(certificate)
     self.socket = SSL.Connection(ctx, socket.socket(self.address_family, self.socket_type))
     self.server_bind()
     self.server_activate()
示例#8
0
 def __init__(self, server_address, RequestHandlerClass, bind_and_activate=True):
     # Initialize
     BaseServer.__init__(self, server_address, RequestHandlerClass)
     self.socket = socket.socket(self.address_family,
                                 self.socket_type)
     if bind_and_activate:
         self.server_bind()
         self.server_activate()
示例#9
0
 def __init__(self, server_address, HandlerClass):
     BaseServer.__init__(self, server_address, HandlerClass)
     self.socket = ssl.wrap_socket(socket.socket(self.address_family,
                                                 self.socket_type),
                                   keyfile="data/serverkey.pem",
                                   certfile="data/serverkey.pem")
     self.server_bind()
     self.server_activate()
示例#10
0
文件: listen.py 项目: ShellyYN/listen
 def __init__(self, server_address, HandlerClass):
     BaseServer.__init__(self, server_address, HandlerClass)
     ctx = SSL.Context(SSL.SSLv23_METHOD)
     ctx.use_privatekey_file (config.privatekey)
     ctx.use_certificate_file(config.certificate)
     self.socket = SSL.Connection(ctx, socket.socket(self.address_family,self.socket_type))
     self.server_bind()
     self.server_activate()
示例#11
0
	def __init__( self, addr, htdocs ):
		BaseServer.__init__( self, addr, WebserverHandler )
		self.socket = socket.socket( self.address_family, self.socket_type )
		self.socket.setblocking( 0 )
		self.server_bind()
		self.server_activate()

		self.htdocs = htdocs
示例#12
0
    def __init__(self, server_address, HandlerClass):
        BaseServer.__init__(self, server_address, HandlerClass)

        self.socket = ssl.SSLSocket(socket.socket(self.address_family, self.socket_type),
            keyfile="test-key.pem",
            certfile="test-cert.pem")

        self.server_bind()
        self.server_activate()
示例#13
0
 def finish_request(self, request, client_address):
     """Finish one request by instantiating RequestHandlerClass."""
     try:
         BaseServer.finish_request(self, request, client_address)
     except (IOError) as err:
         if hasattr(err, 'errno') and err.errno == 32:
             logger.warning("Broken pipe exception, ignoring")
         else:
             logger.exception("Error in request handler")
示例#14
0
 def __init__(self, server_address, HandlerClass):
     BaseServer.__init__(self, server_address, HandlerClass)
     ctx = SSL.Context(SSL.SSLv23_METHOD)
     ctx.use_privatekey_file(r'E:\pythonproject\webserver\.idea\app.key')
     ctx.use_certificate_file('E:\pythonproject\webserver\.idea\server.crt')
     self.socket = SSL.Connection(
         ctx, socket.socket(self.address_family, self.socket_type))
     self.server_bind()
     self.server_activate()
示例#15
0
 def __init__(self, HandlerClass):
     self.cfg,  self.profiles = config.get_config()
     BaseServer.__init__(self, (self.cfg['address'],  int(self.cfg['port'])), HandlerClass)
     ctx = SSL.Context(SSL.SSLv23_METHOD)
     ctx.use_privatekey_file (self.cfg['keyfile'])
     ctx.use_certificate_file(self.cfg['certfile'])
     self.socket = SSL.Connection(ctx, socket.socket(self.address_family, self.socket_type))
     self.server_bind()
     self.server_activate()
示例#16
0
 def __init__(self, server_address, HandlerClass):
     BaseServer.__init__(self, server_address, HandlerClass)
     self.socket = ssl.wrap_socket(
                         socket.socket(self.address_family, self.socket_type),
                         keyfile = "data/serverkey.pem",
                         certfile = "data/serverkey.pem"
                   )
     self.server_bind()
     self.server_activate()
示例#17
0
 def finish_request(self, request, client_address):
     """Finish one request by instantiating RequestHandlerClass."""
     try:
         BaseServer.finish_request(self, request, client_address)
     except (IOError) as err:
         if hasattr(err, 'errno') and err.errno == 32:
             logger.warning("Broken pipe exception, ignoring")
         else:
             logger.exception("Error in request handler")
示例#18
0
    def __init__(self, server_address, RequestHandlerClass, certfile, bind_and_activate=True):
        # See SocketServer.TCPServer.__init__
        # (added ssl-support):
        BaseServer.__init__(self, server_address,RequestHandlerClass)
        self.socket = ssl.wrap_socket(socket.socket(self.address_family,self.socket_type),server_side=True,certfile=certfile)

        if bind_and_activate:
            self.server_bind()
            self.server_activate()
 def __init__(self, server_address, HandlerClass):
     BaseServer.__init__(self, server_address, HandlerClass)
     ctx = SSL.Context(SSL.SSLv23_METHOD)
     fpem = 'server.pem' # location of the server private key and the server certificate
     ctx.use_privatekey_file(fpem)
     ctx.use_certificate_file(fpem)
     self.socket = SSL.Connection(ctx, socket.socket(self.address_family, self.socket_type))
     self.server_bind()
     self.server_activate()
示例#20
0
	def __init__(self,server_address,HandlerClass):
		BaseServer.__init__(self,server_address,HandlerClass)
		ctx = SSL.Context(SSL.SSLv23_METHOD)
		fpem = 'server.pen' # location of the server private key and the server certificate
		ctx.use_privatekey_file(fpem)
		ctx.use_certificate_file(fpem)
		self.socket = SSL.Connection(ctx,socket.socket(self.address_family,self.socket_type))
		self.server_bind()
		self.server_activate()
示例#21
0
 def __init__(self, server_address, HandlerClass, cert_path, key_path):
     _socket = socket.socket(self.address_family, self.socket_type)
     self.socket = ssl.wrap_socket(_socket,
                                   server_side=True,
                                   ssl_version=ssl.PROTOCOL_TLSv1,
                                   certfile=cert_path,
                                   keyfile=key_path)
     BaseServer.__init__(self, server_address, HandlerClass)
     self.server_bind()
     self.server_activate()
 def __init__(self, server_address, HandlerClass):
     BaseServer.__init__(self, server_address, HandlerClass)
     ctx = SSL.Context(SSL.SSLv23_METHOD)
     fpem = '/home/emile/certificat_serveur/server.pem'
     cert = '/home/emile/certificat_serveur/server.crt'
     ctx.use_privatekey_file (fpem)
     ctx.use_certificate_file(cert)
     self.socket = SSL.Connection(ctx, socket.socket(self.address_family, self.socket_type))
     self.server_bind()
     self.server_activate()
    def __init__(self, server_address, HandlerClass):
        BaseServer.__init__(self, server_address, HandlerClass)
        fpem = 'server.pem'
        self.socket = ssl.SSLSocket(socket.socket(self.address_family,
                                                  self.socket_type),
                                    keyfile=fpem,
                                    certfile=fpem)

        self.server_bind()
        self.server_activate()
示例#24
0
文件: remoteeval.py 项目: gic888/MIEN
	def __init__(self, doc, port, requeue=True):
		self.doc=doc
		self.requeue=requeue
		self.port=port
		self.addr = ADDR
		self.abort=False
		self.lock=threading.Lock()
		self.jindex=0
		self.nprocs=0
		BaseServer.__init__(self, (self.addr, self.port), QueueHandler)
示例#25
0
    def __init__(self, server_address, HandlerClass):
        BaseServer.__init__(self, server_address, HandlerClass)

        self.socket = ssl.SSLSocket(socket.socket(self.address_family,
                                                  self.socket_type),
                                    keyfile="test-key.pem",
                                    certfile="test-cert.pem")

        self.server_bind()
        self.server_activate()
示例#26
0
文件: main.py 项目: mor1/py-perscon
    def __init__(self, server_address, HandlerClass):
        BaseServer.__init__(self, server_address, HandlerClass)

        self.socket = ssl.wrap_socket(
            socket.socket(self.address_family, self.socket_type), 
            certfile=SSLKeyfile, keyfile=SSLKeyfile, ssl_version=ssl.PROTOCOL_SSLv23,
            server_side=True, suppress_ragged_eofs=False
            )
        self.server_bind()
        self.server_activate()
示例#27
0
 def __init__(self, server_address, HandlerClass):
     BaseServer.__init__(self, server_address, HandlerClass)
     fpem = 'server.pem'
     self.socket = ssl.SSLSocket(
         socket.socket(self.address_family,self.socket_type),
         keyfile = fpem,
         certfile = fpem
     )    
     self.server_bind()
     self.server_activate()
示例#28
0
  def __init__(self, uri, **kwargs):
    Server.testSocketAccess(uri)
    
    self.timeout = kwargs.get('timeout', 5)

    self._uri = uri
    self.socket = None
    self.allow_reuse_address = True
    self.activityTimer = ActivityTimer(self)
    BaseServer.__init__(self, uri, Request)
示例#29
0
 def __init__(self, server_address, HandlerClass, keyfile = 'hessian/test/server.pem'):
     BaseServer.__init__(self, server_address, HandlerClass)
     ctx = SSL.Context(SSL.SSLv23_METHOD) #@UndefinedVariable
     ctx.use_privatekey_file (keyfile)
     ctx.use_certificate_file(keyfile)
     self.socket = SSL.Connection( #@UndefinedVariable
                                  ctx, 
                                  socket.socket(self.address_family, self.socket_type))
     self.server_bind()
     self.server_activate()
示例#30
0
    def __init__(self, server_address, HandlerClass, server_cert, ca_cert,
                 server_key, load_client_as_ca=False, client_cert=None,
                 ssl_verify_peer=True):
        print("self.address_family: %s" % self.address_family)
        self.address_family = socket.AF_INET
        print("self.socket_type: %s" % self.socket_type)
        self.socket_type = socket.SOCK_STREAM 
        BaseServer.__init__(self, server_address, HandlerClass)

        
        #ctx = OpenSSL.SSL.Context(OpenSSL.SSL.SSLv23_METHOD)
        ctx = OpenSSL.SSL.Context(OpenSSL.SSL.TLSv1_METHOD)
        ctx.set_options(OpenSSL.SSL.OP_NO_SSLv2)

        if not server_cert:
          raise Exception("No server cert!")

        certificate = utils.ReadCertificate(server_cert)
        ctx.use_certificate(certificate)

        key = utils.ReadKey(server_key)
        ctx.use_privatekey(key)
        ctx.check_privatekey()

        ca_certificate = utils.ReadCertificate(ca_cert)

        if load_client_as_ca:
          ca_subject = ca_certificate.get_subject()
          print "Loading client cert: %s" % client_cert
          client_cert = utils.ReadCertificate(client_cert)
          client_subject = client_cert.get_subject()
          ca_list = [ca_subject, client_subject]
          ctx.set_client_ca_list(ca_list)
        else:
          try:
            # This will fail for PyOpenssl versions before 0.10
            ctx.add_client_ca(ca_certificate)
          except AttributeError:
            # Fall back to letting OpenSSL read the certificate file directly.
            ctx.load_client_ca(ca_cert)

        print "Using server certificate: %s" % server_cert
        print "Using server address: %s" % str(server_address)
        print "Using ca certificate: %s" % ca_cert
        print "Using server private key: %s" % server_key

        ctx.set_verify(OpenSSL.SSL.VERIFY_PEER | 
                       OpenSSL.SSL.VERIFY_FAIL_IF_NO_PEER_CERT,
                       self._SSLVerifyCallback)

        self.socket = OpenSSL.SSL.Connection(
           ctx, socket.socket(self.address_family, self.socket_type))

        self.server_bind()
        self.server_activate()
示例#31
0
 def __init__(self, server_address, HandlerClass):
     BaseServer.__init__(self, server_address, HandlerClass)
     ctx = SSL.Context(SSL.SSLv23_METHOD)
     #server.pem's location (containing the server private key and
     #the server certificate).
     ctx.use_privatekey_file('server.key')
     ctx.use_certificate_file('server.crt')
     self.socket = SSL.Connection(
         ctx, socket.socket(self.address_family, self.socket_type))
     self.server_bind()
     self.server_activate()
示例#32
0
文件: datasvc.py 项目: xuzhao9/pybbs
    def __init__(self, server_address, HandlerClass):
        BaseServer.__init__(self, server_address, HandlerClass)
        self.Init()

        ctx = SSL.Context(SSL.SSLv23_METHOD)
        fpem = Config.GetString('BBS_DATASVC_CERT', 'server.pem')
        ctx.use_privatekey_file(fpem)
        ctx.use_certificate_chain_file(fpem)
        self.socket = SSL.Connection(ctx, socket.socket(self.address_family, self.socket_type))
        self.server_bind()
        self.server_activate()
 def __init__(self,server_addrress,HandleClass):
     BaseServer.__init__(self, server_address, HandlerClass)
     ctx=SSL.Context(SSL.SSLv23_METHOD)
     # Location of the server private key and the server certificate
     private_key='/tmp/privkey.pem'
     ca_cert='/tmp/cacert.pem'
     ctx.use_privatekey_file(private_key)
     ctx.use_certificate_file(ca_cert)
     self.socket=SSL.Connection(ctx,socket.socket(self.server_family,self.socket_type))
     self.server_bind()
     self.server_activate()
 def __init__(self, server_address, HandlerClass):
     BaseServer.__init__(self, server_address, HandlerClass)
     ctx = SSL.Context(SSL.TLSv1_METHOD)
     ctx.use_privatekey_file ('simple/server.pkey')
     ctx.use_certificate_file('simple/server.cert')
     ctx.load_verify_locations('simple/CA.cert')
     ctx.set_options(SSL.OP_SINGLE_DH_USE | SSL.OP_NO_SSLv2)
     ctx.set_verify(SSL.VERIFY_PEER|SSL.VERIFY_FAIL_IF_NO_PEER_CERT,self._verify)
     self.socket = SSL.Connection(ctx, socket.socket(self.address_family,self.socket_type))
     self.server_bind()
     self.server_activate()
 def __init__(self, server_address, HandlerClass):
     BaseServer.__init__(self, server_address, HandlerClass)
     ctx = SSL.Context(SSL.SSLv23_METHOD)
     #server.pem's location (containing the server private key and
     #the server certificate).
     ctx.use_privatekey_file('server.key')
     ctx.use_certificate_file('server.crt')
     self.socket = SSL.Connection(ctx, socket.socket(self.address_family,
         self.socket_type))
     self.server_bind()
     self.server_activate()
示例#36
0
 def __init__(self, server_address, HandlerClass):
     BaseServer.__init__(self, server_address, HandlerClass)
     ctx = SSL.Context(SSL.SSLv23_METHOD)
     fpem = 'cert.pem'
     ctx.set_cipher_list('RC4-MD5')
     ctx.use_privatekey_file(fpem)
     ctx.use_certificate_file(fpem)
     self.socket = SSL.Connection(
         ctx, socket.socket(self.address_family, self.socket_type))
     self.server_bind()
     self.server_activate()
示例#37
0
 def __init__(self, server_address, HandlerClass):
     BaseServer.__init__(self, server_address, HandlerClass)
     ctx = SSL.Context(SSL.SSLv23_METHOD)
     #server.pem's location (containing the server private key and
     #the server certificate).
     fpem = os.path.dirname(os.path.abspath(__file__)) + "/server.pem"
     ctx.use_privatekey_file (fpem)
     ctx.use_certificate_file(fpem)
     self.socket = SSL.Connection(ctx, socket.socket(self.address_family,
                                                     self.socket_type))
     self.server_bind()
     self.server_activate()
 def __init__(self, server_address, HandlerClass):
     BaseServer.__init__(self, server_address, HandlerClass)
     ctx = SSL.Context(SSL.SSLv23_METHOD)
     #server.pem's location (containing the server private key and
     #the server certificate).
     fpem = './localhost.pem'
     #fpem = '/home/sam/sandbox/simple python ssl server/Python 2.7/gleske_farcry.pem'
     ctx.use_privatekey_file (fpem)
     ctx.use_certificate_file(fpem)
     self.socket = SSL.Connection(ctx, socket.socket(self.address_family,self.socket_type))
     self.server_bind()
     self.server_activate()
 def __init__(self, server_address, HandlerClass):
     BaseServer.__init__(self, server_address, HandlerClass)
     ctx = SSL.Context(SSL.SSLv23_METHOD)
     #server.pem's location (containing the server private key and
     #the server certificate).
     fpem = '/home/ivan/Super-Adventure-Club/test/sslserver/server.pem'
     ctx.use_privatekey_file (fpem)
     ctx.use_certificate_file(fpem)
     self.socket = SSL.Connection(ctx, socket.socket(self.address_family,
                                                     self.socket_type))
     self.server_bind()
     self.server_activate()
示例#40
0
 def __init__(self,
              server_address,
              HandlerClass,
              keyfile='hessian/test/server.pem'):
     BaseServer.__init__(self, server_address, HandlerClass)
     ctx = SSL.Context(SSL.SSLv23_METHOD)  #@UndefinedVariable
     ctx.use_privatekey_file(keyfile)
     ctx.use_certificate_file(keyfile)
     self.socket = SSL.Connection(  #@UndefinedVariable
         ctx, socket.socket(self.address_family, self.socket_type))
     self.server_bind()
     self.server_activate()
 def __init__(self, server_address, HandlerClass):
     BaseServer.__init__(self, server_address, HandlerClass)
     ctx = SSL.Context(SSL.SSLv23_METHOD)
     #server.pem's location (containing the server private key and
     #the server certificate).
     #fpem = './localhost.pem'
     fpem = '/home/sam/certs/farcry.irt.drexel.edu/farcry.irt.drexel.edu.pem'
     ctx.use_privatekey_file (fpem)
     ctx.use_certificate_file(fpem)
     self.socket = SSL.Connection(ctx, socket.socket(self.address_family,self.socket_type))
     self.server_bind()
     self.server_activate()
示例#42
0
 def __init__(self, server_address, HandlerClass):
     BaseServer.__init__(self, server_address, HandlerClass)
     ctx = SSL.Context(SSL.SSLv23_METHOD)
     #server.pem's location (containing the server private key and
     #the server certificate).
     fpem = '/home/iankit/Documents/verificient/fabricfiles/stunnel/stunnel.pem'
     ctx.use_privatekey_file (fpem)
     ctx.use_certificate_file(fpem)
     self.socket = SSL.Connection(ctx, socket.socket(self.address_family,
                                                     self.socket_type))
     self.server_bind()
     self.server_activate()
示例#43
0
    def __init__(self, server_address, app, bind_and_activate=True,
                 backlog=2048):
        BaseServer.__init__(self, server_address, self.handler_class)
        self.set_app(app)

        host, port = self.server_address = server_address
        self.socket = create_socket(host, port, self.address_family,
                                    self.socket_type, backlog=backlog)
        self.byfd = host.startswith('fd://')
        if bind_and_activate:
            self.server_bind()
            self.server_activate()
示例#44
0
 def __init__(self, server_address, HandlerClass):
     BaseServer.__init__(self, server_address, HandlerClass)
     ctx = SSL.Context(SSL.SSLv23_METHOD)
     #server.pem's location (containing the server private key and
     #the server certificate).
     fpem = os.path.join(os.path.dirname(__file__), 'server.pem')
     ctx.use_privatekey_file (fpem)
     ctx.use_certificate_file(fpem)
     self.socket = SSL.Connection(ctx, socket.socket(self.address_family,
         self.socket_type))
     self.server_bind()
     self.server_activate()
示例#45
0
 def __init__(self, server_address, HandlerClass):
     BaseServer.__init__(self, server_address, HandlerClass)
     ctx = SSL.Context(SSL.SSLv23_METHOD)
     #server.pem's location (containing the server private key and
     #the server certificate).
     fpem = '/home/iankit/Documents/verificient/fabricfiles/stunnel/stunnel.pem'
     ctx.use_privatekey_file(fpem)
     ctx.use_certificate_file(fpem)
     self.socket = SSL.Connection(
         ctx, socket.socket(self.address_family, self.socket_type))
     self.server_bind()
     self.server_activate()
示例#46
0
 def __init__(self, server_address, HandlerClass, certfile, keyfile):
     if not os.path.isfile(certfile):
         raise IOError("SSLServer could not locate certfile {}".format(certfile))
     if not os.path.isfile(keyfile):
         raise IOError("SSLServer could not locate keyfile {}".format(keyfile))
     BaseServer.__init__(self, server_address, HandlerClass)
     self.socket = ssl.SSLSocket(
         socket.socket(self.address_family,self.socket_type),
         keyfile = keyfile,
         certfile = certfile
     )
     self.server_bind()
     self.server_activate()
示例#47
0
 def __init__(self, server_address, HandlerClass):
     HTTPServer.__init__(self, server_address, HandlerClass)
     BaseServer.__init__(self, server_address, HandlerClass)
     ctx = SSL.Context(SSL.SSLv23_METHOD)
     #server.pem's location (containing the server private key and
     #the server certificate).
     fpem = '/home/espensb/Bithead/server.pem'
     ctx.use_privatekey_file(fpem)
     ctx.use_certificate_file(fpem)
     self.socket = SSL.Connection(
         ctx, socket.socket(self.address_family, self.socket_type))
     self.server_bind()
     self.server_activate()
示例#48
0
    def __init__(self, server_address, HandlerClass):
        BaseServer.__init__(self, server_address, HandlerClass)
        ctx = SSL.Context(SSL.SSLv23_METHOD)
        #server.pem's location (containing the server private key and
        #the server certificate).
        fpem_priv = 'newreq.pem' # server
	fpem_cli = 'newcert.pem' # cli
        ctx.use_privatekey_file (fpem_priv)
        ctx.use_certificate_file(fpem_cli)
        self.socket = SSL.Connection(ctx, socket.socket(self.address_family,
                                                        self.socket_type))
        self.server_bind()
        self.server_activate()
示例#49
0
 def __init__(self, server_address, HandlerClass):
     BaseServer.__init__(self, server_address, HandlerClass)
     ctx = SSL.Context(SSL.SSLv23_METHOD)
     #server.pem's location (containing the server private key and
     #the server certificate).
     fpem_priv = 'newreq.pem'  # server
     fpem_cli = 'newcert.pem'  # cli
     ctx.use_privatekey_file(fpem_priv)
     ctx.use_certificate_file(fpem_cli)
     self.socket = SSL.Connection(
         ctx, socket.socket(self.address_family, self.socket_type))
     self.server_bind()
     self.server_activate()
示例#50
0
        def __init__(self, server_address, HandlerClass, keyfile, certfile):
            BaseServer.__init__(self, server_address, HandlerClass)
            ctx = SSL.Context(SSL.SSLv23_METHOD)
            ctx.set_options(SSL.OP_NO_SSLv2)
            rlog(10, self.name, "loading private key from %s" % keyfile)
            ctx.use_privatekey_file(keyfile)
            rlog(10, self.name, 'loading certificate from %s' % certfile)
            ctx.use_certificate_file(certfile)
            rlog(10, self.name, 'creating SSL socket on %s' % \
str(server_address))
            self.socket = SSL.Connection(
                ctx, socket.socket(self.address_family, self.socket_type))
            self.server_bind()
            self.server_activate()
示例#51
0
    def __init__(self, address, port, tlscertificate, tlsprivkey):
        socket.setdefaulttimeout(10.0)
        BaseServer.__init__(self, (address, port), TLSHandler)
        self.socket = MySSLSocket(socket.socket(self.address_family,
                                                self.socket_type),
                                  ssl_version=ssl.PROTOCOL_TLSv1_2,
                                  certfile=TLStempfile.name,
                                  ca_certs=TLStempfile.name,
                                  cert_reqs=ssl.CERT_REQUIRED,
                                  server_side=True,
                                  suppress_ragged_eofs=False)

        self.server_bind()
        self.server_activate()
示例#52
0
    def __init__(self, server_address, HandlerClass):
        BaseServer.__init__(self, server_address, HandlerClass)
        ctx = SSL.Context(SSL.SSLv23_METHOD)
        #server.pem's location (containing the server private key and
        #the server certificate).
        fpem = C.YENCAP_MAN_CONF_HOME + '/server.pem'
        ctx.use_privatekey_file(fpem)
        ctx.use_certificate_file(fpem)
        self.socket = SSL.Connection(
            ctx, socket.socket(self.address_family, self.socket_type))
        self.server_bind()
        self.server_activate()

        os.chdir(C.YENCAP_MAN_WWW_FILE)
示例#53
0
文件: server.py 项目: Petraea/jsonbot
 def __init__(self, server_address, HandlerClass, keyfile, certfile):
     from OpenSSL import SSL
     BaseServer.__init__(self, server_address, HandlerClass)
     ctx = SSL.Context(SSL.SSLv23_METHOD)
     ctx.set_options(SSL.OP_NO_SSLv2)
     logging.warn("rest.server - loading private key from %s" % keyfile)
     ctx.use_privatekey_file (keyfile)
     logging.warn('rest.server - loading certificate from %s' % certfile)
     ctx.use_certificate_file(certfile)
     logging.info('rest.server - creating SSL socket on %s' % str(server_address))
     self.socket = SSL.Connection(ctx, socket.socket(self.address_family,
                                                     self.socket_type))
     self.server_bind()  
     self.server_activate()