title: Java: Determine type of KeyStore from Keystore file
body: <p>So I have an application in which I'm allowing the user to configure the server with HTTPS. The server uses Undertow. To add a HTTPS handler to Undertow, I need to make a call to Keystore.getInstance("JKS") function which returns the implementation based on the provider. Java natively supports only 3 providers(JKS, PKCS12 and JCEKS) but from my understanding, you can add your own provider of Keystore implementation.</p>
  
  <p>So my question is, given just the keystore file, is it possible to determine what type of Keystore it is? I cannot rely on file extension as PKCS12 keystores can be stored in .p12 file extension as well. Is there I can get this value programmatically so that I can pass it to Keystore.getInstance() or do I have to just take that input from the user?</p>