title: Check that a file is certificate or a key
body: <p>I have a problem, I am allowing the used to upload certificate and private key files. Now suppose I have a file whose extension is messed-up (changed knowingly or unknowingly) say to break the system.. I need to put a validation in place that can check and can tell me that the given file is a valid certificate file or private key file or some other file..  </p>
  
  <p>What i was thing was : to check for <code>-- BEGIN CERTIFICATE --</code>, <code>-- BEGIN RSA PRIVATE KEY --</code> in the file content..  Please tell what I am thing is good, or there is some other better solution to this problem..  </p>
  
  <p>Thanks</p>