I already unsuccessfully tried the solution from the article http://social.msdn.microsoft.com/Forums/de-DE/9795271f-33ed-4aa0-b561-31535c95ddb1/unable-to-upload-gateway-client-root-certificate-via-rest-api?forum=WAVirtualMachinesVirtualNetwork&prof=required
Hi I always run into that "Internal Server Error" when I try to upload a RootCert for my created virtual Network "LabNet". I exported the CER as BASE64 from certmgr.msc and tried to upload it manually through the managment Portal which worked, but the same file (i read that file into certData (see code below)) always Fails with the "Internal Server Error" :-(
Any ideas? I am really stuck here. And I already tried to implement all the things from the other article. Like the different x-ms-Version that is different than in the documentation (works neither way though).
Thanks a lot in advance
Andreas
public string ReproFullHardCodeUploadCert() { string certData = "-----BEGIN CERTIFICATE-----\r\n BASE64 ENCODED CERT REMOVED FOR PUBLIC FORUM \r\n-----END CERTIFICATE-----"; string body = "<Binary>"+certData+"</Binary>"; string uri = String.Format("https://management.core.windows.net/{0}/services/networking/{1}/gateway/clientrootcertificates", "SUBSCRIPTION ID REMOVED FOR PUBLIC FORUM","LabNet"); Uri operationUri = new Uri(uri); HttpWebRequest httpWebRequest = CreateHttpWebRequest(operationUri, "POST"); httpWebRequest.ContentType = "application/xml"; httpWebRequest.Headers["x-ms-version"] = "2013-03-01"; using (Stream requestStream = httpWebRequest.GetRequestStream()) { using (StreamWriter streamWriter = new StreamWriter(requestStream, System.Text.UTF8Encoding.UTF8)) { streamWriter.Write(body); } } try { String requestId; using (HttpWebResponse response = (HttpWebResponse)httpWebRequest.GetResponse()) { requestId = response.Headers["x-ms-request-id"]; } return requestId; } catch (WebException wex) { StreamReader sr = new StreamReader(wex.Response.GetResponseStream()); Debug.WriteLine(sr.ReadToEnd()); /* * <Error xmlns="http://schemas.microsoft.com/windowsazure" * xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> * <Code>InternalError</Code> * <Message>The server encountered an internal error. Please retry the request.</Message> * </Error> */ sr.Close(); throw wex; } catch (Exception e) { throw e; } }