title: Convert FileUpload to X509Certificate2
body: <p>How can I convert an uploaded file to an X509Certificate2 variable?</p>
  
  <p>I have tried using the following code but it is not working:</p>
  
  <pre><code>public bool hasPublicKey(FileUpload file)
  {
      bool check = false;
  
      try
      {
           X509Certificate2 cert = (X509Certificate2)file.PostedFile.InputStream;
      }
      catch(Exception)
      {
           check = false;
      }
   }
  </code></pre>