Message10822

Author pradeeppanayal
Recipients pradeeppanayal
Date 2016-03-17.13:15:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1458220523.65.0.53811987152.issue2486@psf.upfronthosting.co.za>
In-reply-to
Content
I am getting the ssl illegal state exception frequently but not always. 

I am using jsonrpc lib with an added wrapper to the method " _request" as follows

@trust_all_certificates
def _request(self, methodname, params, rpcid=None):
    request = dumps(params, methodname, encoding=self.__encoding,
                    rpcid=rpcid, version=self.__version)
    response = self._run_request(request)
    check_for_errors(response)
    return response['result']
and the wrapper is taken from : http://tech.pedersen-live.com/2010/10/trusting-all-certificates-in-jython/ as follows,

def trust_all_certificates(f):
'''Decorator function that will make it so the context of the    decorated method
will run with our TrustManager that accepts all certificates'''
def wrapped(*args, **kwargs):
    # Only do this if running under Jython
    if 'java' in sys.platform:
        from javax.net.ssl import SSLContext
        SSLContext.setDefault(TRUST_ALL_CONTEXT)
        try:
            res = f(*args, **kwargs)
            return res
        finally:
            SSLContext.setDefault(DEFAULT_CONTEXT)
    else:
        return f(*args, **kwargs)
return wrapped
History
Date User Action Args
2016-03-17 13:15:23pradeeppanayalsetrecipients: + pradeeppanayal
2016-03-17 13:15:23pradeeppanayalsetmessageid: <1458220523.65.0.53811987152.issue2486@psf.upfronthosting.co.za>
2016-03-17 13:15:23pradeeppanayallinkissue2486 messages
2016-03-17 13:15:22pradeeppanayalcreate