开发者

Answer password to keytool in batch files

i need use keytool and jarsigner to sign a lot o files here in many folders.

Each time i start sign theses files i need delete the .cert and keystore file to recreate it.

Im on development enviroment and using fake passwd to sign it, after application working the infra people will take care of sign it, i havent access to real certificates.

When i was typing and the keytool -import ....... ,after enter, ask for password i simply type it but in batch it become a problem.

Im on windows 7 here.

I was tried keytool -import ....... < passHere and keytool -import ....... | passHere, too but it doesn't work.

I want turn sign most automatic possible.

There is someone telling about use it programatically here but i simply need it on a bat file.

The password is a fixed value inside batch file.

There is a way to give passwd inline to keytool?

Is possible set an enviroment variable in 'run time' to feed keytool password? how do it ?

There is a way to give passwd inside bath to keytool? I see this but dont help because i'm not a asm developer and not sure if it match problem and im wondering if there is s开发者_如何学JAVAomething more simple.

Thanks


This command works for me (tested it with keytool from jdk 1.6.0.24):

keytool -import -noprompt -file PathToCertificate -alias SomeCertificateAlias -keystore PathToKeyStore -storepass KeyStorePassword


I needed batch creation of a keystore since I don't have access to the remote machine and need to create the keystore automatically. I tried this command (with the -noprompt and -storepass options), but it still asked for a password. I got around this doing an echo <password> | keytool ... with the same options as the other answer, which worked.


I needed to create JKS keystores with keys from a PKCS12 store.

This worked for me:

echo <passphrase>| keytool.exe -importkeystore -srckeystore <source_pkcs12> -srcstoretype pkcs12 -destkeystore <jks_store> -deststoretype JKS -storepass <store_passphrase> -noprompt

The trick was to not have a space between the passphrase and the | pipe symbol, otherwise keytool considers the space part of the passphrase.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜