簡體   English   中英

Python中的Azure服務管理 - ssl.SSLError:[SSL] PEM lib(_ssl.c:2084)

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

我創建了一個.cer文件並將其上傳到Azure管理面板。 我使用Administrator:命令提示符創建了這個。

makecert -sky exchange -r -n "CN=AzureCertificate" -pe -a sha1 -len 2048 -ss My "AzureCertificate.cer"

這是我的代碼:

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()

這是我得到的錯誤:

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)

有人能夠診斷出這個錯誤,我沒有在網上找到太多幫助。

您需要將cert_path設置為: cert_path = 'CURRENT_USER\\\\my\\\\AzureCertificate'

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

Windows上現在支持上面鏈接中“Mac / Linux上的管理證書”部分中所述的打開SSL證書。 它檢測是否應該使用httplib或winhttp的方式是cert_path。 如果它是文件的路徑,它將使用httplib(打開ssl證書)。 如果沒有,它將使用winhttp。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM