I am going to list all management certificates in azure windows signature. And I tried with the following code. But that gives me an exception. And I could find that response is null and the exception message is "The remote server returned an error: (403) Forbidden."
Please help me with this. Msdn is not an example for this :(
using System; using System.Collections.Generic; using System.Net; using System.Security.Cryptography.X509Certificates; using System.Xml; using System.Xml.Linq; class ManagemenCertificateViewer { public static void Runme() { string msVersion = "2012-03-01"; string subscriptionId = "I used the subscription Id here"; try { ListManagementCertificates(subscriptionId, msVersion); } catch (Exception ex) { Console.WriteLine("Exception caught: "); Console.WriteLine(ex.Message); } } private static void ListManagementCertificates(string subscriptionId, string version) { string uriFormat = "https://management.core.windows.net/{0}/certificates"; Uri uri = new Uri(string.Format(uriFormat, subscriptionId)); HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri); request.Method = "GET"; request.Headers.Add("x-ms-version", version); request.ContentType = "application/xml"; XDocument responseBody = null; HttpStatusCode statusCode; HttpWebResponse response; try { response = (HttpWebResponse)request.GetResponse(); } catch (WebException ex) {
source share