我正在尝试使用请求包

时间:2020-03-06 12:06:29

标签: python-2.7 api unix python-requests response

我正在使用请求包。

为我提供了一个授权密钥和一个p12文件。通过使用p12文件,我在Unix服务器中使用以下命令生成了cert.pemkey.pem(无需使用parsephrase(无需手动输入密码)。

我正在传递以下代码,这些代码在使用cmd或IDE的本地计算机上运行正常,但是在Unix服务器上运行该代码时却遇到了问题

openssl pkcs12 -clcerts -nokeys -out certz.pem -in CN=32927_datahub.p12
openssl pkcs12 -nocerts -out keyz.pem -in CN=32927_datahub.p12
openssl rsa -in keyz.pem -out npkeyz.pem

url = "https://enterprise.*****.com/api/mdm/devices/search?lgid=12174"

auth= "CMSURL`1MIIEzAYJKoZIhvcNAQcCoIIEvTCCBLkCAQExCzAJBgUrDgMCGgUAMAsGCSqGSIb3DQEHAaCCAuIwggLeMIIBxqADAgECAhBeimEp+hGZn0dybM5kglsLMA0GCSqGSIb3DQEBDQUAMBgxFjAUBgNVBAMTDTMyOTI3OmRhdGFodWIwHhcNMTkwNjA0MDY1OTEwWhcNMzkwNTMwMDY1OTEwWjAYMRYwFAYDVQQDEw0zMjkyNzpkYXRhaHViMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2XjjQ01S1v1jxeJz+5M7i4661kV/E6LTpYhnnOFiE8db35ieZ/z7FdP19bYc+SmB/YEs2df+VY73Y/XjPcHzLyLKB/uxRfaLYL6IFiV+Co6NZNalKSU8WjplnHI+kYkh/nHzXnjgl3HyrLAVPsWk8bcDv1S2nO7pkvFTsmvNJall3ikmkNAPWEt2SafEbmu/wAhlh39/Aa4CCz+Z7WRZxYKMCS1mVWr2Zp2t+UZAB2OAZiAXIx0DUT6CnHCcS3pkOyUlh5/4ap6HklAJiLsjtty6uMOXmAU/VOXr+jzhRF7Z4giaIu4/aiwYCh9AxZdBx92nSPNWiQ4Z9GjV+Q47lQIDAQABoyQwIjALBgNVHQ8EBAMCBaAwEwYDVR0lBAwwCgYIKwYBBQUHAwIwDQYJKoZIhvcNAQENBQADggEBAJHYb5qY8yHVn/bhBkAx0tYXwQEbAsHAJiTe55g+GrKaDa9GgQ6X6iTRCH1gROuMpx4N0ByvcxxayXH33CULrVovnxl50wLzebgR4RJuJz8577ILy7947MK51Jh2IfN8lBMYSnXT8Com7Ug++8Zk3JRioXCPC0hwhmFO86pRdUkJslO8D8hpxkk9GN+0mhIXgg6IFA6z4ePzAMWcAOUsPH1uRDfrlSKZJmKXGZSqVdtc6ApQ/+xLZ5uUQ8j2fr92jj1V0Mc8S3AQgSU/f8mlWRfwaf0I2pugyODIJjo7CUkPpNMLKqISz0HSk5uNsm/HZU6r6PT7+IR+JPRH6YGjd0MxggGyMIIBrgIBATAsMBgxFjAUBgNVBAMTDTMyOTI3OmRhdGFodWICEF6KYSn6EZmfR3JszmSCWwswCQYFKw4DAhoFAKBdMBgGCSqGSIb3DQEJAzELBgkqhkiG9w0BBwEwHAYJKoZIhvcNAQkFMQ8XDTIwMDIxOTA2NTc0NlowIwYJKoZIhvcNAQkEMRYEFMGVE8gmJoJRNIRcjszHFp5eXpukMA0GCSqGSIb3DQEBAQUABIIBAK4PF9J9YMrZLoZGUrmYdyHqhMg7fD/b0UikbOZxORKYeG771DCWUUmJm3Awk1b7nLCze0UESUBFaQNNocFSx4noZr3X2N8rvg9PVztdTSLIReoty/wqNeb8KTyv0SnliTSsHyFuiwMsIqxauAOuzLXQrf6ZubnwB0xVJmsKnOxiIbZ/AbwC1Oy9sJw5Yx+5ZoTH2JSgwZ3LwwocAIFncAINFyaVEP+rlHhAL1NoOXsvq7uOjoa/l+FAXrchWozquuEOq6G+RQw9N3KQB9PrYij+vn+vmRdUYHrK8AmnxtNlkqJknOoZT33oHpS+ezKyEHtVkZxiPBACztN5GDHZT/g="

head = {'AW-Tenant-Code':"u0WkQqShvxht0GLvZ43ux8jqOrp/mNgVFWhceh7iQz0=",'Content-Type':"application/json",'Authorization':auth}
r = requests.get(url, headers=head, cert=('D:\\DEP3\\certz.pem','D:\\DEP3\\npkeyz.pem'),verify=True)
file=open("D:\\VMWARE_DAT\\data\\b2b\\land\VMWARE\\JSON\\final.json",'w+')
print(r.json())
#print(json.dump(r.json(),file,indent=4))

上面的代码工作正常,我正在使用cmd shell在本地获得响应。

当我尝试在Unix环境中调优相同的代码时遇到了错误,我在该环境中生成了证书和密钥.pem文件

enter image description here

0 个答案:

没有答案