Created
February 25, 2020 19:11
-
-
Save shanku9/e3f6a9c4895f475157a3da2511cd7f47 to your computer and use it in GitHub Desktop.
Request using PFX
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Extract cert and key file from pfx file | |
openssl pkcs12 -in admin.pfx -out certfile.pem -clcerts -nokeys | |
Enter Import Password: | |
MAC verified OK | |
openssl pkcs12 -in admin.pfx -out key.pem -nocerts -nodes | |
Enter Import Password: | |
MAC verified OK | |
''' | |
import requests | |
# Ignore InsecureRequestWarning | |
# import urllib3 | |
# urllib3.disable_warnings() | |
requests.packages.urllib3.disable_warnings() | |
# url format https://domain:port_number | |
base_url = "https://your_server:443" | |
# URL for the call | |
end_point = "/apidocs/v1/" | |
# Test URL | |
url = base_url + end_point | |
cert ="/location/to/certs/certfile.pem" | |
key="/location/to/certs/key.pem" | |
response = requests.request("GET", url, verify=False, cert=(cert,key)) | |
if response.encoding == 'utf-8': | |
for line in response.text.splitlines(): | |
print(line) | |
else: | |
print(response.json()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment