Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is how I converted the cert I created in my question into a format I could use to authenticate my requests to the Azure Service Management API. Smarx's answer also works, and indeed I used the cert created by his technique involving the <code>.publishsettings</code> file to figure out how my converted cert should look.</p> <p>Create your cert by opening up the Visual Studio Command Prompt and typing:</p> <pre><code>makecert -r -pe -a sha1 -n "CN=My Azure Management Certificate" -ss My -len 2048 -sp "Microsoft Enhanced RSA and AES Cryptographic Provider" -sy 24 myazuremanagementcert.cer </code></pre> <p>as directed by <a href="http://msdn.microsoft.com/en-us/library/windowsazure/gg651127" rel="nofollow">http://msdn.microsoft.com/en-us/library/windowsazure/gg651127</a>.</p> <p>Then, open up the Certificate Manager by typing <code>certmgr.msc</code> into the search box. I found my certificate under <code>Certificates - Current User/Personal/Certificates</code>. </p> <p>Right-clicking on the certificate, go to "All Tasks" and click "Export". When prompted, make sure "Yes, export the private key" is selected and export the file as a .PFX (PKCS#12). </p> <p>Here, I moved my .PFX to a Linux VM.</p> <p>Everything from here on follows the steps laid out at <a href="http://blog.scottlowe.org/2005/12/02/certificate-conversion-using-openssl/" rel="nofollow">http://blog.scottlowe.org/2005/12/02/certificate-conversion-using-openssl/</a></p> <p>Opening a terminal, type:</p> <pre><code>openssl pkcs12 -in pfxfilename.pfx -out tempfile.pem </code></pre> <p>This will prompt you both for the password you used to encrypt the .pfx and a new password to use to encrypt the .pem. <em>Do not leave this password blank! I did and was confused as the key was not just left decrypted but rather not included in the new .pem at all</em></p> <p>Separate the key and the certificate in the new .pem into two different files, removing all excess lines other than the <code>----begin/end cert/key----</code> lines. </p> <p>Decrypt the key by typing:</p> <pre><code>openssl rsa -in encryptedkey -out decryptedkey </code></pre> <p>And, recombine the key and cert with:</p> <pre><code>cat decryptedkey certificatefile &gt; finalfile.pem </code></pre> <p>Now, this cert should properly authenticate a service management request to Azure:</p> <pre><code>import httplib sub_id = [subid] conn = httplib.HTTPSConnection('management.core.windows.net', cert_file = 'finalfile.pem') conn.request('GET', '/%s/services/storageservices' % sub_id, headers = {'x-ms-versiojn':'2012-03-01'}) response = conn.getresponse() print reponse.status response.reason </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload