def __init__(self, file=None, dir=None, default=False):
        """
        Creates X509 store and installs lookup method. Optionally initializes
        by certificates from given file or directory.
        """
        #
        # Todo - set verification flags
        #
        self.store = libcrypto.X509_STORE_new()
        if self.store is None:
            raise X509Error("allocating store")
        lookup = libcrypto.X509_STORE_add_lookup(self.store,
                                                 libcrypto.X509_LOOKUP_file())
        if lookup is None:
            raise X509Error("error installing file lookup method")
        if file is not None:
            if pyver == 2:
                fn = file
            else:
                fn = file.encode(sys.getfilesystemencoding())
            if not libcrypto.X509_LOOKUP_ctrl(lookup, 1, fn, 1, None) > 0:
                raise X509Error("error loading trusted certs from file "+file)
        lookup = libcrypto.X509_STORE_add_lookup(self.store,
                                             libcrypto.X509_LOOKUP_hash_dir())
        if lookup is None:
            raise X509Error("error installing hashed lookup method")
        if dir is not None:
            if pyver == 2:
                dr = dir
            else:
                dr = dir.encode(sys.getfilesystemencoding())
            if not libcrypto.X509_LOOKUP_ctrl(lookup, 2, dr, 1, None) > 0:
                raise X509Error("error adding hashed  trusted certs dir "+dir)
        if default:
            if not libcrypto.X509_LOOKUP_ctrl(lookup, 2, None, 3, None) > 0:
                raise X509Error("error adding default trusted certs dir ")
def __init__ ( self , file = None , dir = None , default = False ) : self . store = libcrypto . X509_STORE_new ( ) if self . store is None : raise X509Error ( "allocating store" ) lookup = libcrypto . X509_STORE_add_lookup ( self . store , libcrypto . X509_LOOKUP_file ( ) ) if lookup is None : raise X509Error ( "error installing file lookup method" ) if file is not None : if pyver == 2 : fn = file else : fn = file . encode ( sys . getfilesystemencoding ( ) ) if not libcrypto . X509_LOOKUP_ctrl ( lookup , 1 , fn , 1 , None ) > 0 : raise X509Error ( "error loading trusted certs from file " + file ) lookup = libcrypto . X509_STORE_add_lookup ( self . store , libcrypto . X509_LOOKUP_hash_dir ( ) ) if lookup is None : raise X509Error ( "error installing hashed lookup method" ) if dir is not None : if pyver == 2 : dr = dir else : dr = dir . encode ( sys . getfilesystemencoding ( ) ) if not libcrypto . X509_LOOKUP_ctrl ( lookup , 2 , dr , 1 , None ) > 0 : raise X509Error ( "error adding hashed  trusted certs dir " + dir ) if default : if not libcrypto . X509_LOOKUP_ctrl ( lookup , 2 , None , 3 , None ) > 0 : raise X509Error ( "error adding default trusted certs dir " )
Creates X509 store and installs lookup method. Optionally initializes
        by certificates from given file or directory.