Keytool cannot find an alias

I have a pfx certificate that I need to reference by an alias. The problem is that keytool cannot find this alias even if it appears in the list.

keytool -list -keystore temp.pfx -storetype pkcs12 

gives me the following:

 ... 0c5fc7cef279ca390acd2d6bac9ffcf8_ba0cbbb3-323d-4394-8e76-47838adb2a9c, 08/03/2013, PrivateKeyEntry, ... 

But whenever I try to use keytool to do something with this alias (i.e. export, rename), it gives me an error:

 keytool error: java.lang.Exception: Alias <0c5fc7cef279ca390acd2d6bac9ffcf8_ba0cbbb3-323d-4394-8e76-47838adb2a9c> does not exist 

Any ideas?

+7
source share
1 answer

It turns out that after checking the output of keytool -list on vim, I found the null character at the end of the alias (which does not print to the console). As soon as I added this to the command that references the alias, it worked:

 keytool -keyclone -changealias -v -dest "new_alias" -new newpass -keystore temp.pfx -storetype pkcs12 -alias 0c5fc7cef279ca390acd2d6bac9ffcf8_ba0cbbb3-323d-4394-8e76-47838adb2a9c$'\x00' 

In cases where the very end actually matters: $'\x00' denotes the null character in bash. Keep in mind that this is pretty shell dependent.

+10
source

All Articles