Azure Service Management in Python - ssl.SSLError: [SSL] PEM lib (_ssl.c: 2084)

I created a .cer file and uploaded it to Azure Control Panel. I created this using Administrator: Command Line.

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 am getting:

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)

      

Anyone can diagnose this error, I haven't found much help on the internet.

+3


source to share


1 answer


You need to set cert_path:   cert_path = 'CURRENT_USER\\my\\AzureCertificate'

http://azure.microsoft.com/en-us/documentation/articles/cloud-services-python-how-to-use-service-management/



The public SSL certificates described in the Mac / Linux Management Certificates section of the link above are now supported on Windows. The way it determines if it should use httplib or winhttp in the cert_path. If it is a file path it will use httplib (open ssl certificate). If not, it will use winhttp.

+1


source







All Articles