Certificado del lado del cliente en una aplicación Metro para Windows Azure Service Management

I'm trying to connect to the Windows Azure Service Management API. I have to provide a certificate which I previously uploaded to my azure portal. In .NET, this is very easy, as detallado aquí. In Metro however, you cannot attach a Certificate to the request manually. On the Microsoft forum I found this:

HttpClientHandler aHandler = new HttpClientHandler();
aHandler.ClientCertificateOptions = ClientCertificateOption.Automatic;

HttpClient aClient = new HttpClient(aHandler);
HttpResponseMessage aResp = await aClient.GetAsync("https://[azure service management uri]");

Together with giving the app the capability to use shared certificates, this should select a certificate or present the user an option to select the certificate. The certificate is in my Personal store, and I have even tried to include the certificate in the package manifest, but nothing works. It appears it just doesn't include the certificate in the request.

What is the correct way to call a REST-based API which needs a certiticate within a Metro app?

preguntado el 29 de agosto de 12 a las 11:08

I have tested this out tonight in a Javascript metro app, and there it works using WinJS.xhr! On this side I get a popup screen asking me which certificate I want to use. On the C# side however, this doesn't appear to work using HttpClient or WebRequest. I would love to have a C# solution to this. -

I'm in the same boat :). Works flawlessly with HTML5/JS app. Tried everything but couldn't get it working in XAML/C# App. Do keep an eye on this post on MSDN Forums: social.msdn.microsoft.com/Forums/sv/winappswithcsharp/thread/…. Harin, one of the responders on this thread was actually able to make this work!!! He sent me his code but that didn't work for me either. -

1 Respuestas

I think I have an answer to this. Please check the certificate you're using to authenticate your requests. There needs to be 2 things in that certificate:

  1. Ensure that “Client Authentication” is enabled as one of the certificate purpose.

  2. Ensure that the certificate has “OID” specified for it.

I wrote a blog post about consuming Windows Azure Service Management API in a Windows 8 application which you can read here: http://gauravmantri.com/2012/09/08/consuming-windows-azure-service-management-api-in-a-windows-8-application/. I have covered these two issues and then some more there.

Espero que esto ayude.

Respondido el 09 de Septiembre de 12 a las 08:09

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.