title: Is it possible to generate certificate signing request(.csr) using security framework in iOS?
body: <p>I would like to make HTTPS request with a server require client-certificate authentication. I looked into this <a href="https://stackoverflow.com/questions/10238559/creating-a-seccertificateref-for-nsurlconnection-authentication-challenge?rq=1">Creating a SecCertificateRef for NSURLConnection Authentication Challenge</a>. It worked as expected.</p>
  
  <p>However, it needs to prepare the p12 file which includes the private key. It would be secured as it needs a password to import the p12 file using <code>SecPKCS12Import()</code>.</p>
  
  <p>However, there could be other option. That is the iOS-client should make a certificate signing request(.CSR) and let a third party (the server) sign it.</p>
  
  <p>For my search, I see that I can use <code>SecKeyGeneratePair()</code> for generating a key pair. But I don't see any API that generate a CSR.</p>
  
  <p>Do I really need OpenSSL to achieve this?</p>
  
  <p>Also, a bit off topic, once the iOS-client somehow receives the signed certificate. I can use <code>SecCertificateCreateWithData()</code> to retrieve an <code>SecCertificateRef()</code>. However, to fill in a <code>NSURLCredential</code>. I also need the <code>SecIdentityRef</code> which come from p12 file using <code>SecPKCS12Import()</code>. How can I retrieve a <code>SecIdentityRef</code> without <code>SecPKCS12Import()</code> but just a certificate file like <code>crt</code> or <code>der</code>?</p>