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 893293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:11:47+00:00 2026-05-15T14:11:47+00:00

I have created a certificate basically straight from the keytool example page: keytool -genkey

  • 0

I have created a certificate basically straight from the keytool example page:

keytool -genkey -dname “cn=Anything, ou=Anything, o=Anything, c=US” -alias business -keypass kpi135 -keystore C:\mykeystore -storepass ab987c -validity 1095

I am trying to access this certificate and use the private key portion to digitally sign a portion of text to authenticate with a third party. Below is the code I’m attempting:

   //Add bouncyCastle as a provider
   Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());

   KeyStore keystore = KeyStore.getInstance("JKS");
   keystore.load(new FileInputStream("C:\\mykeystore"), "ab987c".toCharArray());
   Signature sig = Signature.getInstance("MD5withRSA", "BC");
   PrivateKey privateKey = (PrivateKey)keystore.getKey("business", "kpi135".toCharArray()); //Exception here
   sig.initSign(privateKey);
   sig.update("myUID__myNonce".getBytes());
   byte[] digitalSignature = sig.sign();

   System.out.println("Signature Formulated: " + digitalSignature);

I get the following exception:

java.security.InvalidKeyException: Supplied key (sun.security.provider.DSAPrivat
eKey) is not a RSAPrivateKey instance
        at org.bouncycastle.jce.provider.JDKDigestSignature.engineInitSign(Unkno
wn Source)
        at java.security.Signature$Delegate.engineInitSign(Signature.java:1095)
        at java.security.Signature.initSign(Signature.java:480)
        at MainClass.<init>(MainClass.java:15)
        at MainClass.main(MainClass.java:28)

I assume it’s because I’ve somehow created the certificate with the wrong type of key, but I’m not sure I’m finding what I need by digging through the keytool page. It does mention that you can apparently generate a key using -keysig RSA and -sigalg RSA however when I try those flags when creating a certificate I get:

keytool error: java.security.NoSuchAlgorithmException: RSA Signature not availab
le

enter code here
  • 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-05-15T14:11:47+00:00Added an answer on May 15, 2026 at 2:11 pm

    Actually it seems you can add “-keyalg RSA” to the keygen command which alleviates the mismatch issue. I was incorrectly trying both -keyalg and -sigalg in the same keygen command. The code above now executes without exceptions.

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

Sidebar

Related Questions

I have created a certificate using the following SSL command: makecert -r -pe -n
I have certificate created using java class CertAndKeyGen and X500Name and I am able
I have created a RSA certificate which looks like as follows. Certificate: Data: Version:
I have created 3 classes as following Ext.mine.TextParent - Inherting from Textfield Ext.mine.child.TextChildA -
I have created my SSL certificate using Selssl7.exe on server1 but used Cn as
I have created a self-signed certificate on my server. Now I need to import
I have created a Keystore and imported my certificate (issued by an official CA)
I have created a application in iphone and i have provision certificate for testing
I have created a new Facebook app. Whenever I visit the canvas page (https://apps.fac...)
I have created a self generated certificate to sign a DLL. When I load

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.