问题描述
我正在尝试创建一个仪表板,该仪表板将连接到HP ALM。 我现在要完成的工作是使用SSL证书通过Python对ALM进行基本身份验证。
ALM版本12.01
错误:
HTTPSConnectionPool(host ='#####',port = ####):已超过最大重试次数 使用网址: #/ alm-authenticate?%3Calm-authentication%3E%3Cuser%3E #####%3C / user%3E%3Cpassword%3E ####%3C / password%3E%3C / alm-authentication%3E(引起通过SSLError(SSLCertVerificationError(1,'[SSL: CERTIFICATE_VERIFY_Failed]证书验证失败:无法获取 本地发行者证书(_ssl.c:1108)')))
FsstateBackend
输出:
import ssl
import requests
import urllib3
#function to get certificate from server
def _certificate_required(hostname,port=443):
pem_cert = ssl.get_server_certificate((hostname,port),ca_certs=None)
print("Certificate string received")
return pem_cert
urllib3.disable_warnings()
url = "http://##ALM-url##/qcbin/rest/is-authenticated/"
querystring = {"username":"##User##","password":"##pass##"}
headers = {
'token': "####",}
try:
response = requests.request("GET",url,headers=headers,params=querystring,verify = "##/certificate.cer")
print(response.headers)
new_header = response.headers
cert=_certificate_required(hostname="##ALM url##",port=443)
print("Certicate string obtained from server:\n"+cert)
with open('##/certificate.cer','w') as f:
f.write(cert)
print("Certificate updated")
new_url ="https://##ALM url##/qcbin/authentication-point/alm-authenticate"
response = requests.request("POST",new_url,headers=new_header,params="<alm-authentication><user>##USER##</user><password>##PASS##</password></alm-authentication>",verify = "##/certificate.cer")
print(response.text)
print(response.headers)
print(response.status_code)
except Exception as e:
print("Error occured")
print(e)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)