Difference between revisions of "SSL Authentication using httplib with Certificates"
Jump to navigation
Jump to search
PeterHarding (talk | contribs) |
PeterHarding (talk | contribs) |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
<pre> | <pre> | ||
import httplib | import httplib | ||
KEYFILE = path of key file | KEYFILE = path of key file | ||
CERTFILE = path of cert file | CERTFILE = path of cert file | ||
| Line 12: | Line 12: | ||
cert_file = CERTFILE | cert_file = CERTFILE | ||
) | ) | ||
template = """soap template""" | template = """soap template""" | ||
conn.putrequest('POST', 'soapaction') | conn.putrequest('POST', 'soapaction') | ||
conn.putheader("User-Agent", "Python post") | conn.putheader("User-Agent", "Python post") | ||
| Line 19: | Line 21: | ||
conn.putheader("SOAPAction", "\"\"") | conn.putheader("SOAPAction", "\"\"") | ||
conn.endheaders() | conn.endheaders() | ||
conn.send(template) | conn.send(template) | ||
response = conn.getresponse() | response = conn.getresponse() | ||
print response.read() | print response.read() | ||
</pre> | </pre> | ||
[[Category:Python]] | [[Category:Python]] | ||
[[Category: | [[Category:Python httplib]] | ||
[[Category:Examples]] | |||
Latest revision as of 15:08, 1 August 2015
import httplib
KEYFILE = path of key file
CERTFILE = path of cert file
HOSTNAME = host
conn = httplib.HTTPSConnection(
HOSTNAME,
port = port,
key_file = KEYFILE,
cert_file = CERTFILE
)
template = """soap template"""
conn.putrequest('POST', 'soapaction')
conn.putheader("User-Agent", "Python post")
conn.putheader("Content-type", "text/xml; charset=\"UTF-8\"")
conn.putheader("Content-length", "%d" % len(tem))
conn.putheader("SOAPAction", "\"\"")
conn.endheaders()
conn.send(template)
response = conn.getresponse()
print response.read()