標籤:style blog http color os 使用 strong ar for
《Windows Azure Platform 系列文章目錄》
在某些時候,我們需要在Azure PaaS Cloud Service配置HTTPS串連。本章將介紹如何在本地建立認證,然後使用HTTPS串連Azure Cloud Service。
1.建立認證
以管理員身份運行CMD,使用Makecert命令,安裝Azure認證。具體的命令如下:
makecert -sky exchange -r -n "CN=<CertificateName>" -pe -a sha1 -len 2048 -ss My "<CertificateName>.cer"
比如我建立一個認證名叫SSLCertificate
makecert -sky exchange -r -n "CN=SSLCertificate" -pe -a sha1 -len 2048 -ss My "SSLCertificate.cer"
2.匯出私密金鑰
在運行裡,輸入mmc.exe。
在控制台,選擇檔案->添加刪除嵌入式管理單元,添加"認證",選擇"我的使用者賬戶"。
展開"認證-目前使用者"->"個人"->"認證"。選擇SSLCertificate,右鍵,"所有任務",點擊"匯出"。
選擇"是,匯出私密金鑰”,輸入自己的私密金鑰(本文使用123456)。然後將pfx儲存到C盤的根目錄,重新命名為PrivateCertificate.pfx。
3.建立空的Cloud Service
在Windows Azure Portal,建立一個空的雲端服務,命名為LeiSSL。如:
4.點擊Cloud Service,選擇我在步驟三建立的LeiSSL,然後點擊Certificates,最後選擇Upload a certificate
上傳完畢後,可以查看到ThumbPrint,如:
5.將我們儲存在C:\PrivateCertificate.pfx的檔案進行上傳,同時輸入你在步驟二裡匯出的私密金鑰。如:
6.然後在本地,使用管理員身份,運行VS2013。建立一個Cloud Project,並且添加ASP.NET Web Role
7.在專案檔裡,選擇WindowsAzure1,Role,雙擊WebRole1
8.在Certificates功能表列,點擊Add Certificate,將步驟4的Thumbprint輸入到儲存格中
9.再點擊Endpoints功能表列,點擊Add Certificate,設定名稱為HttpsEndpoint,Protocol設定為https,SSL Certificate Name選擇我在步驟8中建立的Certificate1
10.設定完畢後,用VS2013發布Cloud Service
關於發布的步驟,請參考[SDK2.2]Windows Azure Cloud Service (35) 使用VS2013發布Azure Cloud Service
11.我們可以通過https://leissl.cloudapp.net:8080/ 來訪問發布成功的應用程式
Windows Azure Cloud Service (36) 在Azure Cloud Service配置SSL認證