예제 #1
0
 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
예제 #2
0
 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)
예제 #3
0
 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()))
예제 #4
0
 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
예제 #5
0
    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")
예제 #6
0
    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")
예제 #7
0
 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
예제 #8
0
 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