def patch(cls): if cls.patched: NSLog("*** SSL *** Already patched.") return False try: # # The below is very important to allow OpenSSL to do SSL connections on iOS without verifying certs. # If you take this out, blockchain_headers from http://bitcoincash.com will fail, and the # "downloading headers" thing will take ages. So I left this in. # TODO: Figure out how to get bitcoincash.com to not fail with cert verification. # - Calin May 24, 2018 # if (getattr(ssl, '_create_unverified_context', None)): if not cls.origs: cls.origs = (ssl._create_default_https_context, ssl.create_default_context) ssl._create_default_https_context = ssl._create_unverified_context ssl.create_default_context = ssl._create_unverified_context NSLog("*** SSL *** Allow Unverfied Context: ENABLED") else: raise Exception( "pyOpenSSL seems to be missing the '_create_unverified_context' function" ) except: NSLog("*** SSL *** Allow Unverified Context: FAILED (%s)" % (str(sys.exc_info()[1]))) return False cls.patched = True return True
def thrdfunc(config_options): # lazy init of SSL import ssl, sys from electroncash import version NSLog("DeLight lib version: %s (using server protocol: %s)", version.PACKAGE_VERSION, version.PROTOCOL_VERSION) NSLog("Python version: %s", ' '.join(sys.version.split('\n'))) NSLog("OpenSSL version: %s", ssl.OPENSSL_VERSION)
def thrdfunc(config_options): # lazy init of SSL import ssl, sys from electroncash import version, ecc_fast, schnorr NSLog("Electron Cash lib version: %s (using server protocol: %s)", version.PACKAGE_VERSION, version.PROTOCOL_VERSION) NSLog("Python version: %s", ' '.join(sys.version.split('\n'))) NSLog("OpenSSL version: %s", ssl.OPENSSL_VERSION) NSLog("Fast ECC: %s Fast Schnorr: %s", str(ecc_fast.is_using_fast_ecc()), str(schnorr.has_fast_sign()))
def unpatch(cls): if not cls.patched: return False if cls.origs: ssl._create_default_https_context, ssl.create_default_context = cls.origs cls.patched = False NSLog("*** SSL *** Allow Unverfied Context: Disabled") return not cls.patched
def unpatch(cls): if not cls.patched: print('*** WARNING: MonkeyPatches was not active!') return cls._Patch_AES.unpatch() cls._Patch_SSL.unpatch() cls.patched = False NSLog("MonkeyPatches Disabled")
def patch(cls): if cls.patched: print('*** WARNING: MonkeyPatches are already applied!') return cls._Patch_SSL.patch() cls._Patch_AES.patch() cls.patched = True NSLog("MonkeyPatches Applied")
def unpatch(cls): ec_bitcoin.aes_decrypt_with_iv = cls._orig_aes_decrypt_with_iv ec_bitcoin.aes_encrypt_with_iv = cls._orig_aes_encrypt_with_iv cls.patched = False NSLog("*** AES *** Use iOS CommonCrypto: Disabled") return True
def patch(cls): ec_bitcoin.aes_decrypt_with_iv = cls._aes_decrypt_with_iv ec_bitcoin.aes_encrypt_with_iv = cls._aes_encrypt_with_iv cls.patched = True NSLog("*** AES *** Use iOS CommonCrypto: ENABLED") return True