I am using Python zeep to make a SOAP request. For SSL verification, HostHeaderSSLAdapter was added as my URL https://dev_alias:8096/some_soap
, contains an alias rather than the actual host name.
This below code with requests
works OK. So I would assume session
is correct.
import requests
from requests_toolbelt.adapters import host_header_ssl
from zeep.transports import Transport
from zeep import Client, Settings
url = 'https://dev_alias:8096/some_soap'
params = {'param1': 'value1'}
session = requests.Session()
session.verify = 'CertBundle.pem'
session.mount('https://', host_header_ssl.HostHeaderSSLAdapter())
headers = {'SOAPAction': '""', 'Content-Type': 'text/xml; charset=utf-8'}
message = b"<?xml version=\'1.0\' encoding=\'utf-8\'?>....</soap-env:Envelope>"
session.post(url, data=message, headers=headers)
However, when the same session
is used for zeep's Transport
, this code fails.
transport = Transport(session=session)
client = Client(url, transport=transport)
client.service.some_service(params)
SSLError: HTTPSConnectionPool(host='actual_hostname', port=8096):
Max retries exceeded with url: /some_soap (Caused by SSLError(CertificateError(
"hostname 'actual_hostname' doesn't match 'dev_alias'",),))
How can I turn off host name verification with zeep
? Using zeep version 3.4.0 0 and requests 2.22.0