1
我想打印出輸入到證書驗證回調函數的錯誤[我使用pyopenssl]:如何獲得OpenSSL._util.lib.X509_verify_cert_error_string的值作爲Python字符串
def verify_cb(context, certificate, errornum, depth, ok):
if (lib.X509_V_OK == errornum):
print lib.X509_verify_cert_error_string(errornum)
我認爲上面的代碼會打印ok
。但它返回<cdata 'char *' 0x7fff8b400f0f>
。這調試PDB中我得到以下幾點:
(Pdb) lp=lib.X509_verify_cert_error_string(errnum)
(Pdb) type(lp)
<type '_cffi_backend.CData'>
(Pdb) lp[0]
'o'
(Pdb) lp[1]
'k'
(Pdb) lp[2]
'\x00'
有誰知道我怎麼能得到這個值作爲迭代通過這個,我拿一個\x00
字符以外的Python字符串?謝謝。