提问人:Sanjana Basu 提问时间:11/12/2023 更新时间:11/21/2023 访问量:20
无法使用客户端的证书将请求从客户端发送到服务器,也无法使用 Python 进行 SOAP API 调用
Unable to send request from client to server using their certificates and making SOAP API calls using Python
问:
我正在尝试发送请求并尝试在客户端和服务器之间建立连接。我将证书转换为 .pem 文件,并将 .pem 文件中的私钥保存到另一个以 -----BEGIN PRIVATE KEY----- ... -----END PRIVATE KEY-----开头的文件中,并将其保存为.key文件。然后,我将证书文件的私钥添加到服务器证书.pem文件中。我以为通过在客户端和服务器之间建立这种连接。我得到了 200 个,但我没有得到任何回应。请帮忙
import json
import requests
clientCrt = "path to client certificate\\ce.crt"
certificate_secret = "path to client's private key\\pkey.key"
url = "api_end_point_url"
certServer = "path to server certificate\\serv.pem"
headers = {'Content-Type': 'text/xml; charset=utf-8'}
payload = """<?xml version="1.0" encoding="UTF-8" standalone="no"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ns="...">
<soap:Header/>
<soap:Body>
<ns:OrigXARequest>
<Request>
.....
</Request>
</ns:OrigXARequest>
</soap:Body>
</soap:Envelope>"""
response = requests.get(url, data=payload, verify = certServer,
headers=headers, cert=(clientCrt,certificate_secret))
print(response.status_code)
print(response.content)
print(response.text)`
输出
200
b'<?xml version = "1.0" encoding = "UTF-8"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soap:Body><soap:Fault xsi:type="soap:Fault"><faultcode>RTL-API-1002</faultcode><faultstring>Error occurred while invoking the .. Web Service.</faultstring></soap:Fault></soap:Body></soap:Envelope>'
Process finished with exit code 0
答:
0赞
Sanjana Basu
11/21/2023
#1
我能够解决我的问题。问题不在于客户端证书或服务器证书。我没有收到任何响应,因为请求发往错误的SOAP地址。一旦我修复了地址,我的代码就可以工作了。谢谢大家。
下一个:多级 TLS 证书的选项
评论