none
Management API: Setting a SymmetricKey on a new RP

    Dotaz

  • This should hopefully be an easy one.  I am using the ACS Management API to create RPs dynamically.  I need to set a sym

    This article has a code sample:
    http://msdn.microsoft.com/en-us/library/windowsazure/hh135144.aspx#BKMK_8

                string symKey = "SampleTokenSigningSymmetricKey";
                DateTime startDate, endDate;
                startDate = DateTime.UtcNow;
                endDate = DateTime.MaxValue;
    
                RelyingPartyKey relyingPartyKey = new RelyingPartyKey()
                {
    
                    Type = "Symmetric",
                    Usage = "Signing",
                    Value = Encoding.UTF8.GetBytes(symKey),
                    StartDate = startDate.ToUniversalTime(),
                    EndDate = endDate.ToUniversalTime()
                };
             
                //Assign this symmetric key to the selected relying party application 
    
                svc.AddRelatedObject(relyingParty, "RelyingPartyKeys", relyingPartyKey);

    The "problem" is that the "symKey" is getting encoded.  I am using SWT and need to make sure all my RP's have the same key.  From the management UX, I can copy my key which will look something like this (q4gm4VV6wTClCx+LBPr6ERUIbDVGK=) - but when put that into the code above, the result is encoded and thus doesn't match when put into ACS.

    The documentation here is pretty unclear

    http://msdn.microsoft.com/en-us/library/windowsazure/hh124087.aspx

    It just say its a binary value, which make sense because of the Byte[].  Is there a trick to getting my "known" key value up there?

    Thanks

    18. dubna 2012 20:43

Odpovědi

  • Wow, I found it - but it wasn't from any clear MSDN documentation. :(

    The "fix" is to use this

    Value = Convert.FromBase64String(symKey),

    Instead of

    Value = Encoding.UTF8.GetBytes(symKey),

    • Označen jako odpověď ProVega 18. dubna 2012 21:16
    18. dubna 2012 21:16