title: How to use X509 client Certificate in IOS?
body: <p>I have code for <a href="http://www.merchantlink.com/" rel="nofollow">Merchantlink Payment Gateway</a> in Asp.net. Now same thing i want to achieve in IOS .</p>
  
  <p>In this Asp.net Code they using some kind of X509 Certificate and installing it first on localuser machine then passing this certificate in <code>HttpWebRequest</code> Method. The following is the snippet of code used in Asp.net. NOTE: cert <code>Object</code> is <code>Object</code> of <code>X509Certificate2</code>.</p>
  
  <pre><code>webRequest = (HttpWebRequest)WebRequest.Create("Some URI");
  webRequest.ProtocolVersion = HttpVersion.Version10;
  webRequest.Method = "POST";
  webRequest.UserAgent = "AGENT NAME";
  webRequest.ContentType = "text/xml";
  webRequest.ContentLength = requestBytes.Length;
  webRequest.KeepAlive = false;
  webRequest.ClientCertificates.Add(cert);
  </code></pre>
  
  <p>and then </p>
  
  <pre><code>System.Net.ServicePointManager.ServerCertificateValidationCallback =
      delegate(Object sender2, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
      { return true; };
  
      using (Stream requestStream = webRequest.GetRequestStream())
      {
          requestStream.Write(requestBytes, 0, requestBytes.Length);
          using (HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse())
          {
              Stream dataStream = webResponse.GetResponseStream();
              StreamReader reader = new StreamReader(dataStream);
              string responseFromServer = reader.ReadToEnd();
              txtResponse.Text = responseFromServer;
          }
      }
  </code></pre>
  
  <p>I don't know how can I achieve this in Objective C for IOS  can anyone please Let me Guide For this that how can we add Client Certificate with <code>NSURLRequest</code> and how to load the certificate in IOS and send with <code>NSUrlRequest</code>.</p>