2014-01-30 66 views
0

我正在使用Ubuntu 12.04 LTS。 在上傳的Windows Azure帳戶.cer文件中。來自Python的Windows Azure服務管理有證書問題

我的Python腳本是:

#!/usr/bin/python 
from azure import * 
from azure.servicemanagement import * 

azureId = "XXXXXXXXXXXXXXXXXXXXX"; 
certificate_path= "/home/dharampal/Desktop/azure.pem"; 

sms = ServiceManagementService(azureId,certificate_path) 
print sms 
result = sms.list_locations() 
print result 

當腳本運行到時候讓拋出ServiceManagementService對象,但證書相關的錯誤。腳本的

輸出爲:

<azure.servicemanagement.servicemanagementservice.ServiceManagementService object at 0xb7259f2c> 
Traceback (most recent call last): 
    File "available_locations_list.py", line 13, in <module> 
    result = sms.list_locations() 
    File "/usr/local/lib/python2.7/dist-packages/azure/servicemanagement/servicemanagementservice.py", line 796, in list_locations 
    Locations) 
    File "/usr/local/lib/python2.7/dist-packages/azure/servicemanagement/servicemanagementclient.py", line 96, in _perform_get 
    response = self._perform_request(request) 
    File "/usr/local/lib/python2.7/dist-packages/azure/servicemanagement/servicemanagementclient.py", line 83, in _perform_request 
    resp = self._filter(request) 
    File "/usr/local/lib/python2.7/dist-packages/azure/http/httpclient.py", line 144, in perform_request 
    self.send_request_headers(connection, request.headers) 
    File "/usr/local/lib/python2.7/dist-packages/azure/http/httpclient.py", line 125, in send_request_headers 
    connection.endheaders() 
    File "/usr/lib/python2.7/httplib.py", line 954, in endheaders 
    self._send_output(message_body) 
    File "/usr/lib/python2.7/httplib.py", line 814, in _send_output 
    self.send(msg) 
    File "/usr/lib/python2.7/httplib.py", line 776, in send 
    self.connect() 
    File "/usr/lib/python2.7/httplib.py", line 1161, in connect 
    self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file) 
    File "/usr/lib/python2.7/ssl.py", line 381, in wrap_socket 
    ciphers=ciphers) 
    File "/usr/lib/python2.7/ssl.py", line 141, in __init__ 
    ciphers) 
ssl.SSLError: [Errno 336265218] _ssl.c:351: error:140B0002:SSL routines:SSL_CTX_use_PrivateKey_file:system lib 

我在哪裏做錯了嗎? 如果有人遇到同樣的問題並得到解決方案,請幫助我。 沒有谷歌,但無法找到解決方案。

回答

0

你的代碼對我來說看起來很好,所以我不確定你爲什麼看到失敗,但我可以指出你在complete example in Python創建一個pem,上傳cer,並在Python中顯示一些服務管理代碼。

它可能更像是你的pem是如何創建的。 Python的服務管理工作對我來說與PEM和使用以下命令(然後上傳相應的CER到Windows Azure管理證書店)創建CER:

openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem -subj "/CN=This Name Shows in the Portal" 
openssl x509 -inform pem -in mycert.pem -outform der -out mycert.cer 

注意「-subj」參數是很方便的控制文本在Windows Azure門戶中顯示證書,以便您可以區分它們。

還有一個更長的list of Windows Azure papers,其中幾個顯示使用Python的示例(包括上面引用的一個)。

0

這是我在Ubuntu 12.04 LTS上得到的確切錯誤,如果certificate_path不正確(目錄或文件名中的拼寫錯誤)。所以請仔細檢查你的是否正確。

相關問題