你能帮我解决m2crypto吗?
以下代码是返回'HTTP / 1.1 403 Forbidden'服务器。 证书和私钥未加载到代码中:
from M2Crypto import Rand, SSL, httpslib, threading , BIO , X509 , RSA
ctx = SSL.Context('sslv23')
store = ctx.get_cert_store()
bio = BIO.MemoryBuffer()
bio.write( str( open( 'certi.pem', 'r' ).read() ) )
store.add_x509( X509.load_cert_bio(bio) )
# or
# store.add_x509( X509.load_cert_string( str(open( 'certi.pem', 'r' ).read()) ) )
ctx.set_verify( SSL.verify_none, depth=1 )
ctx.set_info_callback()
h = httpslib.HTTPSConnection( ‘Server’, 443, ssl_context=ctx )
h.set_debuglevel(1)
h.request( 'mysoap' )
当我这样做时,它有效:
from M2Crypto import Rand, SSL, httpslib, threading , BIO , X509 , RSA
ctx = SSL.Context('sslv23')
ctx.load_cert_chain( str( 'certi.pem' ) )
ctx.set_verify( SSL.verify_none, depth=1 )
ctx.set_info_callback()
h = httpslib.HTTPSConnection( ‘Server’, 443, ssl_context=ctx )
h.set_debuglevel(1)
h.request( 'mysoap' )
感谢的