Reputation: 4636
I have created a .cer file and uploaded that to Azure Management Panel. I created this using Administrator: Command Prompt.
makecert -sky exchange -r -n "CN=AzureCertificate" -pe -a sha1 -len 2048 -ss My "AzureCertificate.cer"
This is my code:
from azure import *
from azure.servicemanagement import *
subscription_id = '<MY SUBSCRIPTION ID>'
cert_path = r'C:\AzureCertificate.cer'
sms = ServiceManagementService(subscription_id,cert_path)
result = sms.list_locations()
This is the error I get:
Traceback (most recent call last):
File "<pyshell#37>", line 1, in <module>
result = sms.list_locations()
File "C:\Python33\lib\site-packages\azure-0.8.1-py3.3.egg\azure\servicemanagement\servicemanagementservice.py", line 939, in list_locations
Locations)
File "C:\Python33\lib\site-packages\azure-0.8.1-py3.3.egg\azure\servicemanagement\servicemanagementclient.py", line 108, in _perform_get
response = self._perform_request(request)
File "C:\Python33\lib\site-packages\azure-0.8.1-py3.3.egg\azure\servicemanagement\servicemanagementclient.py", line 95, in _perform_request
resp = self._filter(request)
File "C:\Python33\lib\site-packages\azure-0.8.1-py3.3.egg\azure\http\httpclient.py", line 182, in perform_request
connection = self.get_connection(request)
File "C:\Python33\lib\site-packages\azure-0.8.1-py3.3.egg\azure\http\httpclient.py", line 143, in get_connection
host, int(port), cert_file=self.cert_file)
File "C:\Python33\lib\http\client.py", line 1186, in __init__
context.load_cert_chain(cert_file, key_file)
ssl.SSLError: [SSL] PEM lib (_ssl.c:2063)
Is anyone able to diagnose this error, I haven't found much help online.
Upvotes: 3
Views: 1584
Reputation: 96
You'll need to set cert_path to this:
cert_path = 'CURRENT_USER\\my\\AzureCertificate'
Open SSL certificates as described in the 'Management certificates on Mac/Linux' section in the above link are now supported on Windows. The way it detects if it should use httplib or winhttp is by the cert_path. If it's a path to a file, it will use httplib (open ssl certificate). If not, it will use winhttp.
Upvotes: 1