Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8362263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:54:06+00:00 2026-06-09T11:54:06+00:00

I have a keystore with a key pair generated by the following command: keytool

  • 0

I have a keystore with a key pair generated by the following command:

keytool -genkeypair -v -alias test-agent -keypass test-agent -storepass 123456.ABC -keystore test-agent.keystore -storetype JKS

I fill the requested information for the certificate and the store with the key pair is generated correctly.

The following command:

keytool -list -keystore test-agent.keystore -storepass 123456.ABC -storetype JKS

Returns:

Keystore type: JKS
Keystore provider: SUN

Your keystore contains 1 entry

test-agent, Jul 13, 2012, PrivateKeyEntry, 
Certificate fingerprint (MD5): 7B:8F:D7:25:FF:34:D0:EF:44:87:46:E5:BF:18:C6:BF

Now I add the keystore file to my build path and try to load it with the following java code running on an OSX Lion:

public void loadKeyStore() {
  try {
    final Provider p = Security.getProvider("SUN"); 
    final KeyStore keystore = KeyStore.getInstance("JKS",p);

    final InputStream keyStoreInStream = this.getClass().getClassLoader().getResourceAsStream("test-agent.keystore");
    if ( keyStoreInStream == null ) throw new RuntimeException("No keystore found!");

    final char[] password = "123456.ABC".toCharArray();
    try {
      keystore.load(keyStoreInStream, password);
    } catch (Exception e) {
      log.error(String.format("Security library error! [%s]",e.getCause()),e);
    }
  } catch (KeyStoreException e) {
    log.error("Can't initialize security library!",e);
  }
}

The following exception is thrown:

java.io.IOException: Invalid keystore format
at sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:633)
at sun.security.provider.JavaKeyStore$JKS.engineLoad(JavaKeyStore.java:38)
at java.security.KeyStore.load(KeyStore.java:1185)

I’ve already tried to use PKCS12 (set both for keytool and in the code, respectively the provider in this case should be SunJSSE) which results in another exception:

java.io.IOException: DerInputStream.getLength(): lengthTag=111, too big.
at sun.security.util.DerInputStream.getLength(DerInputStream.java:544)
at sun.security.util.DerValue.init(DerValue.java:347)
at sun.security.util.DerValue.<init>(DerValue.java:303)
at com.sun.net.ssl.internal.pkcs12.PKCS12KeyStore.engineLoad(PKCS12KeyStore.java:1200)
at java.security.KeyStore.load(KeyStore.java:1185)

I have no clue what the problem is. Can anybody give me a hint?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T11:54:07+00:00Added an answer on June 9, 2026 at 11:54 am

    I found the solution. It was actually a problem with the deployment of my project. I use maven and its resource plugin does encode all files in the resource folder using UTF8. This encoding corrupted the keystore.
    The solution is to add an ignore filter option to the pom file and tell maven not to encode the keystore file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have generated the keystore and its inner key. Then I have my signed
http://developer.android.com/tools/publishing/app-signing.html I have a keystore that I already have an alias and password for.
I have imported a certificate into a private ~/.keystore file: keytool -list Enter keystore
I try to get Key from KeyStore. I created a keystore by Keytool: keytool
I have the following question on java keystores and keytool. I assume that a
Keystore files I have used in my web application expired last week. I generated
keytool -exportcert -alias mykeystore -keystore mykeystore| openssl sha1 -binary | openssl base64 hello, I
I have following wildcard certificate files from GlobalSign Authority. root.crt intermediate.crt private.key I want
I have PKCS#12 keystore that I've sucessfully imported in my browser for accessing a
I have a problem with a keystore in pkcs12 format, which contains a private

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.