ANT build: [signjar] enter passphrase for keystore: - eclipse

I have created a project in eclipse and while trying to build the project from command prompt the following is asked:
[signjar] jarsigner error: java.lang.RuntimeException: keystore load: C:\Documents
and Settings\Gopakumar\.keystore (The system cannot find the file specified)
[signjar] Enter Passphrase for keystore:
BUILD FAILED
D:\Score\build.xml:556: The following error occurred while executing this line:
D:\Score\build.xml:147: jarsigner returned: 1
I have created keystore file using keytool in the project directory, exactly where build.xml resides.
But it doesn't prompt for the passphrase?

Try it:
Make a StoreFile with "keytool" command:
keytool -genkey -keystore YourKeyStoreFileAtPojectDirectory -storepass YourPassStoreString -keyalg rsa -alias YourKeyString -keypass YourPassKeyString -validity 99999 -storepass YourPassStoreString -dname "cn=XXYYZZ, o=XXYYZZ, l=YourCity, S=YourState, c=YourCountry"
and put the signjar block below in your build.xml:
<signjar destDir="signed"
alias="YourKeyString"
keypass="YourPassKeyString"
keystore="YourKeyStoreFileAtPojectDirectory"
storepass="YourPassStoreString"
digestalg="SHA1"
sigalg="MD5withRSA"
>

Related

Keystore file doesn't exist. Unable to get SHA1 key

Unable to get SHA1 key, it is showing error about path, Keystore file doesn't exist.
Tried multiple numbers of solutions,
I am using the following command
keytool -list -v -keystore c:\users\your_user_name\.android\debug.keystore -alias androiddebugkey -storepass android -keypass android
The keystore file does not exists, you have to create it yourself.
Here is the procedure : Generate android release and debug keystores
I had the same problem but I tried below command and interestingly it worked for me under Windows 10.
keytool -list -keystore debug.keystore

How to Export certificate key to PEM format?

My keystore is deleted, and I try to chat with Google playstore developer and I ask that my keystore app be reset, then they sent instructions like this:
Alternatively, you can use the following command line to generate a
new key:
keytool -genkeypair -alias upload -keyalg RSA -keysize 2048 -validity 9125 -keystore keystore.jks
This key must be a 2048 bit RSA key and have 25-year validity.
Export the certificate for that key to PEM format:
keytool -export -rfc -alias upload -file upload_certificate.pem -keystore keystore.jks
Reply to this email and attach the upload_certificate.pem file.
My question is how to Export the certificate for that key to PEM format?
I try to using keytool.exe in folder C:\Program Files\Android\Android Studio\jre\bin the command prompt keytool.exe can not been write (force close)
keytool is provided in JDK, not JRE. You can install a JDK 1.8 for example and use keytool command from the path C:\Program Files\Java\JDK_1.8\bin\keytool.exe in Windows CMD terminal in Administrator mode(preferably).
The commands you provided are meant to generate a keypair and to export the certificate. So, if you have a proper keytool installed, you can execute your commands successfully and export the certificate.
For exporting certificate, if path not given it will export the ceritificate in bin folder.

build release Ionic does not generate

I'm trying to build the APK to post my plea on Ionic in the Play Store.
But when it comes to the command below I get the error:
PS C:\Projetos\XXX> jarsigner -verbose -sigalg SHA1withRSA
-digestalg SHA1 -keystore android.keystore platforms/android/app/build/outputs/apk/release/app-release-unsigned.apk
android-app-key Picked up _JAVA_OPTIONS: -Xmx512M Enter Passphrase for
keystore: jarsigner:
unable to open jar file:
platforms/android/app/build/outputs/apk/release/app-release-unsigned.apk
And the release is not generated in the APK folder. Can someone help me?
This problem may occur because of the following reasons :
app-release-unsigned.apk does not exist
when executing above command you are not in the release folder, release folder can be found in platforms/android/app/build/outputs/apk/release
keystore does not exist
Verify that you are following these steps
after running ionic cordova build --release android make sure the build is successful and release folder is created under, the path is platforms/android/app/build/outputs/apk/release.
once release folder is created navigate to that folder through terminal
once you reach there generate key store by running following command keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000
you can change the key name to anything, in this example the key name is my-release-key, alias name is also up to you, here alias name is alias_name.
the key will be created under the release folder, save this key somewhere else to publish subsequent builds, also save alias name.
Once key is created run jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore app-release-unsigned.apk alias_name here put the same alias name in place of alias_name and keystore name in place of my-release-key.keystore what you choose in step 4, make sure you release apk name is same as app-release-unsigned.apk if it is different change it as well.
in the end run zipalign -v 4 app-release-unsigned.apk myapp.apk, to compress you app, this will create the compressed apk with name myapp.apk it is the same apk that you will use to publish.
Checked whether android.keystore is located in C:\Projetos\XXX directory. Also check app-release-unsigned.apk is present on platforms/android/app/build/outputs/apk/release/app-release-unsigned.apk this path.
I was typing the wrong command. The correct one to generate is
ionic cordova build --release
and then, to generate the key for the first time, I used these commands:
keytool -genkey -v -keystore xxx.keystore -alias xxx-app-key -keyalg RSA -keysize 2048 -validity 10000
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore GestaoDespesas.keystore platforms\android\app\build\outputs\apk\release\app-release-unsigned.apk xxx-app-key
.\zipalign -v 4 platforms\android\app\build\outputs\apk\release\xxx.apk xxx.apk

delete a cert from a truststore when the alias has unusual characters (?)

Using keytool from the command-line, I added a new cert to a store. But the anger-inducing window manager that I find myself currently stuck with manages to fail at cut-and-paste, and replaced one of the characters of the alias with a ? character. How do I change or delete that alias?
keytool -list -keystore truststore
Enter keystore password:
Keystore type: JKS
Keystore provider: SUN
Your keystore contains 4 entries
hail.ucc.nau.edu:8636-cert-1?, Dec 1, 2017, trustedCertEntry,
.....
keytool -delete -keystore truststore -alias 'hail.ucc.nau.edu:8636-cert-1?'
Enter keystore password:
keytool error: java.lang.Exception: Alias <hail.ucc.nau.edu:8636-cert-1?> does not exist
.....
keytool -delete -keystore truststore -alias 'hail.ucc.nau.edu:8636-cert-1\?'
Enter keystore password:
keytool error: java.lang.Exception: Alias <hail.ucc.nau.edu:8636-cert-1\?> does not exist
.....
keytool -delete -keystore truststore -alias 'hail.ucc.nau.edu:8636-cert-1'
Enter keystore password:
keytool error: java.lang.Exception: Alias <hail.ucc.nau.edu:8636-cert-1> does not exist
Thanks for any assistance,
- rob.
The special character you are seeing, may not be that actual character as suggested by #Pavel Lechev in the comment. If the keytool delete doesn't work, you can use the KeyStore Explorer software to do it. It has nice GUI providing all the keytool functionalities.
Or you could write a small tool/class using KeyStore api to delete your unwanted alias. You could list out all the aliases, identify it, and delete it (to identify the alias, you could do startsWith()).

Jar signing -validity property

I used the -validity property of the keytool to generate a keystore and self sign a jar. During the process, I saw the debug message that says
[info] Warning:
[info] This jar contains entries whose signer certificate will expire within six
months.
I am using the following commands,
keytool -genkey -alias signFiles -keypass mypass -keystore mystore -storepass mypass-alias store -validity 365
keytool -selfcert -keystore mystore -alias store
Am I doing something wrong here? Actually I wanted to sign the jar with a certificate for 1 year.
Cheers,
J
Add -validity 365 to your -selfcert command.