2
votes

I am having some problems using the ACS Management API and symmetric keys. When I add a service identity to ACS via the API and setup a symmetric key it seems like ACS is changing the key I am sending in.

If I pass in "xyz123" as my value for a symmetric key... when I go to the ACS management portal and look at that value its a different string; lets say "AHDyDG6236=".

If I ask the API for the value it returns to me "xyz123" (ServiceIdentityKey.Value).

The value you need to login is "AHDyDG6236=" but there is no way to get this value without going to the ACS portal and clicking on the "show key" button?

Is there anyway to get the usable value for a symmetric key without having to go into the ACS management portal?

here is some sample code that illustrates what I am talking about. Its based off the example found here: http://msdn.microsoft.com/en-us/library/hh135148.aspx

    var svc = ManagementServiceHelper.CreateManagementServiceClient();
    var password = Encoding.UTF8.GetBytes("password");
    var serviceIdentity = svc.CreateServiceIdentity("testSI", password, ServiceIdentityKeyType.Symmetric, ServiceIdentityKeyUsage.Password);
    serviceIdentity.Description = "service identity for testing";
    svc.SaveChangesBatch();
    var svc2 = ManagementServiceHelper.CreateManagementServiceClient();
    var si = svc2.GetServiceIdentityByName("testSI");
    Console.WriteLine(Encoding.UTF8.GetChars(si.ServiceIdentityKeys[0].Value)); //prints out "password"

After you run this code go to ACS portal and click on the symmetric key and then click "show key" and it shows a generated/hashed value... this is the value you need in order to authenticate... but there is no way to get that value from the API?

2

2 Answers

2
votes

The problem you are running into is in Encoding.UTF8.GetBytes("password").

The string that is sent to the server is encoded into base64, so you need to use a different function to get your byte array. Convert.FromBase64String("password")

The example on this page is wrong, but I have contacted their team to let them know and hopefully they will fix it. How to use Access Control Service

0
votes

I'd expect that it would ignore the key you send - you create the service identity and ACS would generate a new key and make that available to you for future sessions. See "Certificates and Keys Management Guidelines" on this page: http://www.windowsazure.com/en-us/manage/services/other/manage-acs/ to get a feel for how ACS allows you to mange keys.