Catfish
Catfish

Reputation: 19294

Keytool giving error for Illegal option: -alias

I'm trying to import a certificate to my cacerts file in my java installation.

This command seems to give me the error "Illegal option: -alias myappProd".

$ keytool -import -alias "myappProd" -keystore /Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/jre/lib/security/cacerts -file /Users/myuser/Downloads/certs/javaprod.cer 
Illegal option:  -alias myappProd

How can I get past this issue?

Upvotes: 6

Views: 23635

Answers (5)

Fahad Mustafa
Fahad Mustafa

Reputation: 27

In my case, I had to type the command to resolve the issue. but ignore the first back slash "\" in the statement. Instead of

keytool -list -v \\
-alias androiddebugkey -keystore %USERPROFILE%\.android\debug.keystore

type this

keytool -list -v -alias androiddebugkey -keystore %USERPROFILE%\.android\debug.keystore

Upvotes: 0

Yoshita Mahajan
Yoshita Mahajan

Reputation: 453

When you face this issue Keytool giving error for Illegal option: -alias

Try typing the whole command instead of copy pasting the command in command prompt .You wont face any issue.

Upvotes: 0

Eduardo
Eduardo

Reputation: 2280

This might sound silly, but was happening also to me.

I typed the command instead of using copy/paste into terminal, that worked.

Apparently the hyphen was different

Upvotes: 11

M.A.Naseer
M.A.Naseer

Reputation: 343

Try removing the quotes around the "myappProd" in alias value.

so the command should be

keytool -import -alias myappProd -keystore /Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/jre/lib/security/cacerts -file /Users/myuser/Downloads/certs/javaprod.cer 

Upvotes: 0

Cristian Meneses
Cristian Meneses

Reputation: 4041

OSX includes its own certificate and credentials management tool, which name is also keytool.

The most probable cause is that you are using OSX's keytool instead of Java keytool (as this provides the -alias option)

Use the full path for Java keytool on the command line, which is JAVA_HOME/bin/keytool

Upvotes: 2

Related Questions