Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Network programming 对等验证期间发送的两个证书。为什么?_Network Programming_Pyopenssl - Fatal编程技术网

Network programming 对等验证期间发送的两个证书。为什么?

Network programming 对等验证期间发送的两个证书。为什么?,network-programming,pyopenssl,Network Programming,Pyopenssl,服务器: def cert_check(conn,cert,errnum,depth,ok): print 'Got cert',cert.get_subject() return ok 客户: ctx = SSL.context(SSL.TLSv1_METHOD) ctx.set_verify(SSL.VERIFY_PEER,verify_cb) ctx.use_private_key_file('server.key') ctx.use_certificate_file('

服务器:

def cert_check(conn,cert,errnum,depth,ok):
    print 'Got cert',cert.get_subject()
    return ok
客户:

ctx = SSL.context(SSL.TLSv1_METHOD)
ctx.set_verify(SSL.VERIFY_PEER,verify_cb)
ctx.use_private_key_file('server.key')
ctx.use_certificate_file('server.crt')
ctx.load_verify_locations('ca.crt')
在客户端和服务器端,我如何获得两个证书。一个没有CommonName,另一个具有正确的CommonName=myownserver.com/myownclient.com

上述所有文件只有一个密钥/证书。
另外,我猜第一个打印的证书是ca.crt,因为它是唯一没有任何公共名称的证书。但是为什么会发生这种情况呢?

这取决于为验证设置的
深度

从手册页 当前上下文允许的证书链验证的最大深度。此外,深度的默认值是
9

ctx = SSL.context(SSL.TLSv1_METHOD)
ctx.set_verify(SSL.VERIFY_PEER,verify_cb)
ctx.use_private_key_file('client.key')
ctx.use_certificate_file('client.crt')
ctx.load_verify_locations('ca.crt')