title: "Wrong version of key store" error. How can I create a version=1 keystore certificate?
body: <p>I am having trouble using SSL, as I am getting the following error related to my keystore (self-created and self-signed using keytool per: <a href="http://developer.android.com/tools/publishing/app-signing.html" rel="nofollow noreferrer">http://developer.android.com/tools/publishing/app-signing.html</a>):</p>
  
  <blockquote>
    <p>08-14 20:55:23.044: W/System.err(5430): java.io.IOException: Wrong
    version of key store.     08-14 20:55:23.060: W/System.err(5430): at
    org.bouncycastle.jce.provider.JDKKeyStore.engineLoad(JDKKeyStore.java:812)
    ...</p>
  </blockquote>
  
  <p>The error thrown in the <code>JDKKeyStore.java</code> class arises in the following code:       </p>
  
  <blockquote>
    <p>Blockquote
    From JDKKeyStore.java:<br>
    if (version != STORE_VERSION)
            {
                if (version != 0)
                {
                    throw new IOException("Wrong version of key store.");
                }
            }</p>
    
    <p>Blockquote</p>
  </blockquote>
  
  <p>In this case STORE_VERSION = 1, and my version=3 based on reading the details of the certificate held by the keystore I have created.  I do not know how to generate a keystore containing a version=1 certificate.</p>
  
  <p>I found this answer helpful: 
  <a href="https://stackoverflow.com/questions/6933103/wrong-version-keystore-when-doing-https-call">wrong version keystore when doing https call</a></p>
  
  <p>however it calls for creating the keystore using the following parameters:        </p>
  
  <blockquote>
    <p>-storetype BKS<br>
    -provider org.bouncycastle.jce.provider.BouncyCastleProvider<br>
    -providerpath /path/to/bouncycastle.jar</p>
  </blockquote>
  
  <p>However, when I try to create the keytool (using the terminal app on Mac) using these parameters:              </p>
  
  <blockquote>
    <p>keytool -genkeypair -v -alias androiddebugkey -keyalg RSA -keysize
    2048 -validity 10000 -keypass android -keystore
    /Users/djames/dropbox/bc146keystore/debug.keystore -storepass android
    -providerclass org.bouncycastle.jce.provider.BouncyCastleProvider –providerpath /Users/djames/dropbox/bc146keystore/</p>
  </blockquote>
  
  <p>(where /Users/djames/dropbox/bc146keystore/ is the path to the bouncy castle jar: bcprov-jdk16-146.jar)</p>
  
  <p>I get the following error:                  </p>
  
  <blockquote>
    <p>keytool error: java.lang.RuntimeException: Usage error, ?providerpath
    is not a legal command java.lang.RuntimeException: Usage error,
    ?providerpath is not a legal command  at
    sun.security.tools.KeyTool.parseArgs(KeyTool.java:375)    at
    sun.security.tools.KeyTool.run(KeyTool.java:171)  at
    sun.security.tools.KeyTool.main(KeyTool.java:166)</p>
  </blockquote>
  
  <p>I do not understand what this is telling me.  If I use: keytool -help it tells me that the following are valid options for the -genkeypair option:             </p>
  
  <blockquote>
    <p>-genkeypair  [-v] [-protected]
           [-alias ]
           [-keyalg ] [-keysize ]
           [-sigalg ] [-dname ]
           [-validity ] [-keypass ]
           [-keystore ] [-storepass ]
           [-storetype ] [-providername ]
           [-providerclass  [-providerarg ]] ...
           [-providerpath ]</p>
  </blockquote>
  
  <p>But in the Oracle docs java version 6 that I am using
  (<a href="http://docs.oracle.com/javase/6/docs/technotes/tools/solaris/keytool.html" rel="nofollow noreferrer">http://docs.oracle.com/javase/6/docs/technotes/tools/solaris/keytool.html</a>)<br>
  it tells me that these are the options:</p>
  
  <blockquote>
    <p>-genkeypair {-alias alias} {-keyalg keyalg} {-keysize keysize} {-sigalg sigalg} [-dname dname] [-keypass keypass] {-validity valDays}
    {-storetype storetype} {-keystore keystore} [-storepass storepass]
    {-providerClass provider_class_name {-providerArg provider_arg}} {-v}
    {-protected} {-Jjavaoption}</p>
  </blockquote>
  
  <p>which does not include the <code>-providerpath option</code>.  Why the discordance?
  (If I do not use the -providerpath option, then I get an unknown class exception at the option: <code>"-providerclass org.bouncycastle.jce.provider.BouncyCastleProvider"</code>...)</p>
  
  <p>When I google: keytool -providerpath<br>
  I get nothing helpful to resolve this. </p>
  
  <p>I am not sure how to solve my keystore version problem without solving my keytool problem.  Any suggestions appreciated.</p>
  
  <p>Jim</p>
  
  <pre><code>(Mac OSX 10.6.8 if relevant)
  </code></pre>