0

I want to Add service certificate to my CloudService of Azure via REST API. Currently I have this:

heres my Request Body: based on this documentation

<?xml version="1.0" encoding="utf-8"?>
<CertificateFile xmlns="http://schemas.microsoft.com/windowsazure">
<Data>MIIB3TCCAUagAwIBAgIQfgPuTBadfItGHpKyYRiRoTANBgkqhkiG9w0BAQUFADAtMSswKQYDVQQDHiIAYwBlAGQAdgBpAGwAbABcAGMAZQBkAHYAaQBsAGwAMAAwMB4XDTEzMDcxNTA4MjIwN1oXDTE0MDcxNTE0MjIwN1owLTErMCkGA1UEAx4iAGMAZQBkAHYAaQBsAGwAXABjAGUAZAB2AGkAbABsADAAMDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA2AB6hYWdqu/IG2Jo17tuHpmVsxNqGG5ROnNTtKZd4c7UtQ287EW5McRXqkfBmiwGIe3Pb3S0bd0q51YhT1WhQkGMMwwYLiAmALBct4OK3KNodl0t+rSO5R0Wq9YIaLq3o5HTGAR4wdKhaC/n1uJWPzD+TjkRRHnfEagWPtVjsMECAwEAATANBgkqhkiG9w0BAQUFAAOBgQCBLwjd3e1PaxvEy+Y1nqpTX8q/0ZsS2jVjCgRti0vehLGFlDEbL2rMhzGMo9zjQbXFzGCInMukFUhEI+OWkOBnBIIiYvTkKIFQWpLN7imIiRVuuqGFwslmESBySSO40M56jPXZ7/D0g8d8WDCfO1YoneDv4CuJE97lMTTyEjUJwg==</Data>
  <CertificateFormat>cer</CertificateFormat>
</CertificateFile>

but it gives me error:The specified certificate's file format is invalid. The certificate file must be a Base64-encoded .pfx file.

Im certain about the certificate in Base64. What I did to get this is I used and upload manually the same My.cer file to different cloudservice and use List Service Certificate to view its Base64.

4

1 回答 1

5

您的问题的简单答案是Service Management API documentation is screwed up. 本质上,API 不关心CertificateFormat节点,您必须始终通过pfx那里。您还需要提供Passwordnode 以及那里没有任何值,因为您正在上传cer文件。因此,基于所有这些,请尝试以下作为您的请求正文:

<?xml version="1.0" encoding="utf-8"?>
<CertificateFile xmlns="http://schemas.microsoft.com/windowsazure">
<Data>MIIB3TCCAUagAwIBAgIQfgPuTBadfItGHpKyYRiRoTANBgkqhkiG9w0BAQUFADAtMSswKQYDVQQDHiIAYwBlAGQAdgBpAGwAbABcAGMAZQBkAHYAaQBsAGwAMAAwMB4XDTEzMDcxNTA4MjIwN1oXDTE0MDcxNTE0MjIwN1owLTErMCkGA1UEAx4iAGMAZQBkAHYAaQBsAGwAXABjAGUAZAB2AGkAbABsADAAMDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA2AB6hYWdqu/IG2Jo17tuHpmVsxNqGG5ROnNTtKZd4c7UtQ287EW5McRXqkfBmiwGIe3Pb3S0bd0q51YhT1WhQkGMMwwYLiAmALBct4OK3KNodl0t+rSO5R0Wq9YIaLq3o5HTGAR4wdKhaC/n1uJWPzD+TjkRRHnfEagWPtVjsMECAwEAATANBgkqhkiG9w0BAQUFAAOBgQCBLwjd3e1PaxvEy+Y1nqpTX8q/0ZsS2jVjCgRti0vehLGFlDEbL2rMhzGMo9zjQbXFzGCInMukFUhEI+OWkOBnBIIiYvTkKIFQWpLN7imIiRVuuqGFwslmESBySSO40M56jPXZ7/D0g8d8WDCfO1YoneDv4CuJE97lMTTyEjUJwg==</Data>
  <CertificateFormat>pfx</CertificateFormat>
  <Password></Password>
</CertificateFile>

非常感谢@AzureCoderfromhttp://elastacloud.com/让我朝着正确的方向前进。

于 2013-08-09T09:14:55.377 回答