How to use the certifi.core function in certifi

To help you get started, we’ve selected a few certifi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cpbotha / nvpy / nvpy / nvpy.py View on Github external
def get_appdir():
    # setup appdir
    if hasattr(sys, 'frozen') and sys.frozen:
        if hasattr(sys, '_MEIPASS'):
            # PyInstaller
            appdir = sys._MEIPASS

            # WORKAROUND: Bug that always raise the SSLCertVerificationError from urlopen()
            #             when CPython is not installed.

            # Use certificate from certifi only if cafile could not find by ssl.
            # See https://github.com/pyinstaller/pyinstaller/pull/3952
            import ssl
            if ssl.get_default_verify_paths().cafile is None:
                import certifi
                os.environ['SSL_CERT_FILE'] = certifi.core.where()
        else:
            # py2exe
            appdir, _ = os.path.split(sys.executable)

    else:
        dirname, _ = os.path.split(os.path.realpath(__file__))
        if dirname and dirname != os.curdir:
            appdir = dirname
        else:
            appdir = os.getcwd()

    # make sure it's the full path
    appdir_full_path = os.path.abspath(appdir)
    return appdir_full_path
github JannickWeisshaupt / OpenDFT / src / little_helpers.py View on Github external
def fix_requests_if_frozen():
    def override_where():
        """ overrides certifi.core.where to return actual location of cacert.pem"""
        # change this to match the location of cacert.pem
        return find_data_file('/data/cacert.pem')

    # is the program compiled?
    if hasattr(sys, "frozen"):
        import certifi.core

        os.environ["REQUESTS_CA_BUNDLE"] = override_where()
        certifi.core.where = override_where

        # delay importing until after where() has been replaced
        import requests.utils
        import requests.adapters
        # replace these variables in case these modules were
        # imported before we replaced certifi.core.where
        requests.utils.DEFAULT_CA_BUNDLE_PATH = override_where()
        requests.adapters.DEFAULT_CA_BUNDLE_PATH = override_where()
github th3-z / kf2-magicked-admin / magicked_admin / magicked_admin.py View on Github external
)
parser.add_argument('-s', '--skip_setup', action='store_true',
                    help=_('Skips the guided setup process'))
args = parser.parse_args()

banner()
settings = Settings(skip_setup=args.skip_setup)

REQUESTS_CA_BUNDLE_PATH = find_data_file("./certifi/cacert.pem")


if hasattr(sys, "frozen"):
    import certifi.core

    os.environ["REQUESTS_CA_BUNDLE"] = REQUESTS_CA_BUNDLE_PATH
    certifi.core.where = REQUESTS_CA_BUNDLE_PATH

    import requests.utils
    import requests.adapters

    requests.utils.DEFAULT_CA_BUNDLE_PATH = REQUESTS_CA_BUNDLE_PATH
    requests.adapters.DEFAULT_CA_BUNDLE_PATH = REQUESTS_CA_BUNDLE_PATH


class MagickedAdmin:
    def __init__(self):
        phone_home()
        signal.signal(signal.SIGINT, self.terminate)
        self.stop_list = []
        self.sigint_count = 0

    def make_server(self, name):
github JannickWeisshaupt / OpenDFT / little_helpers.py View on Github external
def fix_requests_if_frozen():
    def override_where():
        """ overrides certifi.core.where to return actual location of cacert.pem"""
        # change this to match the location of cacert.pem
        return find_data_file('/data/cacert.pem')

    # is the program compiled?
    if hasattr(sys, "frozen"):
        import certifi.core

        os.environ["REQUESTS_CA_BUNDLE"] = override_where()
        certifi.core.where = override_where

        # delay importing until after where() has been replaced
        import requests.utils
        import requests.adapters
        # replace these variables in case these modules were
        # imported before we replaced certifi.core.where
        requests.utils.DEFAULT_CA_BUNDLE_PATH = override_where()
        requests.adapters.DEFAULT_CA_BUNDLE_PATH = override_where()

certifi

Python package for providing Mozilla's CA Bundle.

MPL-2.0
Latest version published 3 months ago

Package Health Score

91 / 100
Full package analysis

Similar packages