codingoutloud
9/22/2012 - 9:49 PM

Create a Windows Azure Management certificate for use with the Service Management API. This is also useful for using the "Publish" option fr

Create a Windows Azure Management certificate for use with the Service Management API. This is also useful for using the "Publish" option from Visual Studio. A -private option can be used to also create a .pvk. You will need the private key (.pvk) if you

@echo off
rem - Generate a self-signed certificate useful for use with the Windows Azure Service Management API 

if .%1.==.. goto USAGE
if .%2.==.. goto USAGE
if "%3"=="-private" goto PRIVATE

makecert.exe -r -pe -n %1 -ss My -sky exchange -sp "Microsoft Enhanced RSA and AES Cryptographic Provider" -sy 24 %2.cer
goto END

:PRIVATE

makecert.exe -r -pe -n %1 -ss My -sky exchange -sp "Microsoft Enhanced RSA and AES Cryptographic Provider" -sy 24 -sv %2.pvk %2.cer
goto END

:USAGE

echo.
echo USAGE: 
echo make-waz-management-cert COMMON-NAME-STRING FILESPEC-WITHOUT-EXTENSION [-private]
echo Including the optional -private parameter will prompt for passwords and will create FILESPEC-WITHOUT-EXTENSION.pvk 
echo in addition to FILESPEC-WITHOUT-EXTENSION.cer.
echo.
echo EXAMPLE:
echo %0 "CN=WAZ Mgmt (Bill Wilder)" billw-waz-mgmt
echo.
echo RESULTS IN:
echo makecert.exe -r -pe -n "CN=WAZ Mgmt (Bill Wilder)" -ss My -sky exchange -sp "Microsoft Enhanced RSA and AES Cryptographic Provider" -sy 24 billw-azure-mgmt.cer
echo.
echo To include the local machine name as part of your certificate name, change the first parameter to something like:
echo    "CN=WAZ Mgmt (Bill Wilder - %%COMPUTERNAME%%)"
echo Note that the local machine name is less useful when the full certificate (private key) is being shared across multiple
echo machines (so they can all publish with the same credentials) since the "local" machine name is no longer correct (or meaningful).
echo.

:END