Beispiel #1
0
    def GetSSLPaths(self):

        # create ssl keys

        cert_here = os.path.exists(self._ssl_cert_path)
        key_here = os.path.exists(self._ssl_key_path)

        if cert_here ^ key_here:

            raise Exception(
                'While creating the server database, only one of the paths "{}" and "{}" existed. You can create a db with these files already in place, but please either delete the existing file (to have hydrus generate its own pair) or find the other in the pair (to use your own).'
                .format(self._ssl_cert_path, self._ssl_key_path))

        elif not (cert_here or key_here):

            HydrusData.Print('Generating new cert/key files.')

            if not HydrusEncryption.OPENSSL_OK:

                raise Exception(
                    'The database was asked for ssl cert and keys to start either the server or the client api in https. The files do not exist yet, so the database wanted to create new ones, but unfortunately PyOpenSSL is not available, so this cannot be done. If you are running from source, please install this module using pip. Or drop in your own client.crt/client.key or server.crt/server.key files in the db directory.'
                )

            HydrusEncryption.GenerateOpenSSLCertAndKeyFile(
                self._ssl_cert_path, self._ssl_key_path)

        return (self._ssl_cert_path, self._ssl_key_path)
Beispiel #2
0
        def TWISTEDSetup():

            cls._ssl_cert_path = os.path.join(TestController.DB_DIR,
                                              'server.crt')
            cls._ssl_key_path = os.path.join(TestController.DB_DIR,
                                             'server.key')

            # if db test ran, this is still hanging around and read-only, so don't bother to fail overwriting
            if not os.path.exists(cls._ssl_cert_path):

                HydrusEncryption.GenerateOpenSSLCertAndKeyFile(
                    cls._ssl_cert_path, cls._ssl_key_path)

            context_factory = twisted.internet.ssl.DefaultOpenSSLContextFactory(
                cls._ssl_key_path, cls._ssl_cert_path)

            reactor.listenSSL(
                HC.DEFAULT_SERVER_ADMIN_PORT,
                ServerServer.HydrusServiceAdmin(cls._serverside_admin_service),
                context_factory)
            reactor.listenSSL(
                HC.DEFAULT_SERVICE_PORT + 1,
                ServerServer.HydrusServiceRepositoryFile(
                    cls._serverside_file_service), context_factory)
            reactor.listenSSL(
                HC.DEFAULT_SERVICE_PORT,
                ServerServer.HydrusServiceRepositoryTag(
                    cls._serverside_tag_service), context_factory)

            reactor.listenTCP(
                45866,
                ClientLocalServer.HydrusServiceBooru(
                    cls._local_booru, allow_non_local_connections=False))
Beispiel #3
0
 def GetSSLPaths( self ):
     
     # create ssl keys
     
     cert_here = os.path.exists( self._ssl_cert_path )
     key_here = os.path.exists( self._ssl_key_path )
     
     if cert_here ^ key_here:
         
         raise Exception( 'While creating the server database, only one of the paths "{}" and "{}" existed. You can create a db with these files already in place, but please either delete the existing file (to have hydrus generate its own pair) or find the other in the pair (to use your own).'.format( self._ssl_cert_path, self._ssl_key_path ) )
         
     elif not ( cert_here or key_here ):
         
         HydrusData.Print( 'Generating new cert/key files.' )
         
         HydrusEncryption.GenerateOpenSSLCertAndKeyFile( self._ssl_cert_path, self._ssl_key_path )
         
     
     return ( self._ssl_cert_path, self._ssl_key_path )