Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the alias of a key within a keystore?

I signed my JWS application MemorizEasy with a key whose alias is:

memofile.reference.emma.jar=/Users/simpatico/.netbeans/6.8/modules/ext/emma.jar

I don't remember why I chose such a long alias. I suspect it was memo only, but in my project settings I have:

jnlp.signjar.alias=memofile.reference.emma.jar=/Users/simpatico/.netbeans/6.8/modules/ext/emma.jar

I'm now updating the application and using maven I need to specify the alias as:

<keystorealias>memofile.reference.emma.jar=/Users/simpatico/.netbeans/6.8/modules/ext/emma.jar
</keystorealias>

Yet that doesn't work. Trying another key with alias mjee it works.

So could I change the alias of the key? If so, how? Otherwise, why wouldn't Maven accept my alias?

like image 399
simpatico Avatar asked Aug 14 '10 11:08

simpatico


People also ask

Can I change keystore alias?

You can use the java keytool to change a private key alias in a keystore. In many respects, it's a competing utility with openssl for keystore, key, and certificate management.

What is the alias in keystore?

An alias is specified when you add an entity to the keystore using the -genseckey command to generate a secret key, -genkeypair command to generate a key pair (public and private key) or the -importcert command to add a certificate or certificate chain to the list of trusted certificates.

How do I change my alias keystore password?

You can change the default keystore password as follows: Change the keystore password in the keystore using the following command: $ keytool -storepasswd -keystore /path/to/security/keystore. jceks -storetype JCEKS -storepass 'changeit' -new 'newPassword'

How do I remove an alias from a keystore?

Check the contents of the trust store by entering the following in the command prompt: <JAVA_HOME>\bin\keytool -list -v -keystore truststore -storepass access . Note the alias names of the certificates you want to remove. Enter <JAVA_HOME>\bin\keytool -delete -alias <alias name> -keystore truststore.


1 Answers

It is possible to duplicate a key in a keystore with the keyclone command of keytool:

keytool -keyclone -alias "your-very-very-long-alias" -dest "new-alias" -keypass keypass -new new_keypass -keystore /path/to/keystore -storepass storepass

The changealias command changes the alias for an existing entry:

keytool -changealias -alias "your-very-very-long-alias" -destalias "new-alias" -keypass keypass -keystore /path/to/keystore -storepass storepass

For those that want to be prompted to enter password just remove the respective password flags (changealias example):

keytool -changealias -alias "your-very-very-long-alias" -destalias "new-alias" -keystore "/path/to/keystore"
like image 180
Jcs Avatar answered Oct 05 '22 07:10

Jcs