title: C# equivalent to Java SSL-socket-connection
body: <p>Hey guys I'm trying to write an AXL-client (SOAP) for the Cisco Unified Communications Manager. For that purpose I need to establish an ssl-connection to the AXL-service. Unfortunatly I dont know much about all that ssl-stuff. </p>
  
  <p>However I was able to find a working Java-example, that does, what I want. The problem is, i need that in C#.NET. So I'm hoping, that someone could "translate" the following Java-code in a C#-version. But it has to do exactly the same, espacially the authentication and certificate-stuff.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>    String sAXLSOAPRequest = "...";
      byte[] bArray = null; // buffer for reading response from
      Socket socket = null; // socket to AXL server
      OutputStream out = null; // output stream to server
      InputStream in = null; // input stream from server
  
      X509TrustManager xtm = new MyTrustManager();
      TrustManager[] mytm = { xtm };
      SSLContext ctx = SSLContext.getInstance("SSL");
      ctx.init(null, mytm, null);
      SSLSocketFactory sslFact = (SSLSocketFactory) ctx.getSocketFactory();
  
      socket = (SSLSocket) sslFact.createSocket("192.168.1.100", Integer.parseInt("8443"));
      in = socket.getInputStream();
      // send the request to the server
      // read the response from the server
      StringBuffer sb = new StringBuffer(2048);
      bArray = new byte[2048];
      int ch = 0;
      int sum = 0;
      out = socket.getOutputStream();
      out.write(sAXLSOAPRequest.getBytes());
  
      while ((ch = in.read(bArray)) != -1) {
          sum += ch;
          sb.append(new String(bArray, 0, ch));
      }
      socket.close();
      // output the response to the standard output
      System.out.println(sb.toString());
  </code></pre>
  
  <p>and this is the MyTrustManager-Class:</p>
  
  <pre><code>public class MyTrustManager implements X509TrustManager {
  MyTrustManager() {
      // create/load keystore
  }
  
  public void checkClientTrusted(X509Certificate chain[], String authType)
          throws CertificateException {
  }
  
  public void checkServerTrusted(X509Certificate chain[], String authType)
          throws CertificateException {
  }
  
  public X509Certificate[] getAcceptedIssuers() {
      return null;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Any help would be appreciated.</p>
  
  <p>Thanks</p>
  
  <p>edit: sorry i should have mentioned: youre right i can generate a proxy-class, but sadly its not working properly. cisco did a really bad job with that (not to mention the really bad documentation). the proxy class throws some xml-errors when parsing some responses. so i have to do it manually for that cases... </p>
  
  <p>i'll worry about the certificate security later</p>