Unable to sign apk with jarsigner - bash

#echo off
set spassw="password"
set kpassw="password"
cordova build android --release --keystore="developer.keystore" --storePassword=%spassw% --alias=developer --password=%kpassw% --prod
del app-release-unsigned.apk
move e:\MobileJs\chatapp\ChatApp\platforms\android\app\build\outputs\apk\release\app-release-unsigned.apk e:\MobileJs\chatapp\ChatApp\
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore developer.keystore app-release-unsigned.apk developer
ERROR: jarsigner error: java.lang.RuntimeException: keystore load: Invalid keystore format
I wrote a cordova build script and I cant seem to sign the APK
this is what my keystore generation looks like
keytool -genkey -v -keystore developer.keystore -alias developer -keyalg RSA -keysize 2048 -validity 10000
Password: password
What is your first and last name?
[Unknown]: First Last
What is the name of your organizational unit?
[Unknown]: n/a
What is the name of your organization?
[Unknown]: n/a
What is the name of your City or Locality?
[Unknown]: City
What is the name of your State or Province?
[Unknown]: State
What is the two-letter country code for this unit?
[Unknown]: US
could it be the n/a

you can refer here for keystore generation. enter link description here after generating keystore you can sign enter link description here your apk. After following these procedure if you are not able to generate feel free to ask.

Related

Custom signed efi getting invalid. "Certificate type not approved for application."

I'm trying to boot an efi loader signed with my custom keys. I've already enrolled its public key in mokmanager, still it is getting blocked in uefi when secure boot is turned on. It looks like the efi is not signed properly.
[root#hp-fedora]/tmp/test# ls
DB.auth DB.crt DB.key KEK.cer KEK.esl mkkeys.sh noPK.auth PK.auth PK.crt PK.key refind_x64.efi.signed
DB.cer DB.esl KEK.auth KEK.crt KEK.key myGUID.txt noPK.esl PK.cer PK.esl refind_x64.efi
[root#hp-fedora]/tmp/test# openssl x509 -in DB.crt -out DB.cer -outform DER
[root#hp-fedora]/tmp/test# sbsign --key DB.key --cert DB.crt --output refind_x64.efi.signed refind_x64.efi
Signing Unsigned original image
[root#hp-fedora]/tmp/test# pesign --show-signature --in=refind_x64.efi.signed
---------------------------------------------
certificate address is 0x7f338a625f88
Content was not encrypted.
Content is detached; signature cannot be verified.
The signer's common name is mykeys DB
No signer email address.
Signing time: Thu Aug 11, 2022
There were certs or crls included.
---------------------------------------------
[root#hp-fedora]/tmp/test# pesigcheck -i refind_x64.efi.signed -n 0 -c DB.cer
Searching db DB.cer
Searching db DB.cer
Certificate type not approved for application.
pesigcheck: "refind_x64.efi.signed" is invalid.

Accidentally removed my app keystore file

I have an application on Google Play, and I want to release an update but I accidentally clicked the - button on the Signing Identity tab in the Distribute manager and now I cannot find the old keystore file, even not in the trash. Is this file totally lost?
For Windows:
Locate the Xamarin debug.keystore file used to sign the app. By default, the keystore used to sign debug versions of a Xamarin.Android application can be found in the following location:
C: \ Users \ USERNAME \ AppData \ Local \ Xamarin \ Mono for Android \ debug.keystore
Information about a key store is obtained by running the command keytool.exefrom the JDK. This tool is typically located in the following location:
C: \ Program Files (x86) \ Java \ jdk VERSION \ bin \ keytool.exe
Add the directory containing keytool.exe to the environment variable. Open a command prompt and run using the following command:
keytool.exe -list -v -keystore "%LocalAppData%\Xamarin\Mono for Android\debug.keystore" -alias androiddebugkey -storepass android -keypass android
When run, keytool.exe should return the following text. The MD5: and SHA1: labels identify the respective signatures:
Alias name: androiddebugkey
Creation date: Aug 19, 2014
Entry type: PrivateKeyEntry
Certificate chain length: 1
Certificate[1]:
Owner: CN=Android Debug, O=Android, C=US
Issuer: CN=Android Debug, O=Android, C=US
Serial number: 53f3b126
Valid from: Tue Aug 19 13:18:46 PDT 2014 until: Sun Nov 15 12:18:46 PST 2043
Certificate fingerprints:
MD5: 27:78:7C:31:64:C2:79:C6:ED:E5:80:51:33:9C:03:57
SHA1: 00:E5:8B:DA:29:49:9D:FC:1D:DA:E7:EE:EE:1A:8A:C7:85:E7:31:23
SHA256: 21:0D:73:90:1D:D6:3D:AB:4C:80:4E:C4:A9:CB:97:FF:34:DD:B4:42:FC:
08:13:E0:49:51:65:A6:7C:7C:90:45
Signature algorithm name: SHA1withRSA
Version: 3
The Documents here: Mention the same Steps for Mac if u want to have a read through that, Otherwise From my Knowledge if you have completely lost the Upload Key, You have to contact the app store to generate you a new one.

Xamarin UI testing - preinstalled apk

There is an apk installed on the emulator manually. I want to start testing this application. You cannot reinstall it using Xamarin UI Tests. AppInitializer.cs contains :
string keyStore = #"C:\...\Certificate\Mycompany.keystore";
return ConfigureApp
.Android
.InstalledApp("com.myapk.test")
.PreferIdeSettings()
.KeyStore(
keyStore,
"passw",
"passw",
"\"alias\"")
.EnableLocalScreenshots()
.StartApp();
When I run the test through Test Explorer, I catch the Exception:
System.Exception : Failed to execute: C:\Program Files\Android\jdk\microsoft_dist_openjdk_1.8.0.25\bin\jarsigner.exe -sigalg SHA1withRSA -digestalg SHA1 -signedjar "C:\Users\user\AppData\Local\Temp\uitest\a-287A94...D0807\23248\SignedTestServer.apk" -storepass passw -keypass passw -keystore "C:\...\Certificate\Mycompany.keystore" "C:\Users\user\AppData\Local\Temp\uitest\a-287A...D0807\TestServer.apk" ""alias"" - exit code: 1
Only one alias can be specified
Please type jarsigner -help for usage
Ok, I've just executed it manually :
jarsigner.exe -sigalg SHA1withRSA -digestalg SHA1 -signedjar "C:\Users\user\AppData\Local\Temp\uitest\a-287A94...D0807\23248\SignedTestServer.apk" -storepass passw -keypass passw -keystore "C:...\Certificate\Mycompany.keystore" "C:\Users\user\AppData\Local\Temp\uitest\a-287A...D0807\TestServer.apk" "alias"
After that I got a new apk file called SignedTestServer.apk. I've copied it into folder :
C:\Users\user\AppData\Local\Temp\uitest\a-287A943C412ED6ED5DEB1675E7FDF91843FD0807
and rerun tests.

No signatures files found in META-INF. Cannot proceed. (RuntimeError)

Resign
D:\test>bundle exec calabash-android resign app-staging.apk
D:\test>
When i do run/build
D:\test>bundle exec calabash-android run app-staging.apk
No test server found for this combination of app and calabash version. Recreating test server.
*** WARNING: You must use ANSICON 1.31 or higher (https://github.com/adoxa/ansicon/) to get coloured output on Windows
WARNING: skipped META-INF/CERT.RSA as unsafe
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/calabash-android-0.9.6/lib/calabash-android/helpers.rb:188:in block (2 levels) in fingerprint_from_apk': No s re files found in META-INF. Cannot proceed. (RuntimeError) from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/calabash-android-0.9.6/lib/calabash-android/helpers.rb:170:inchdir'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/calabash-android-0.9.6/lib/calabash-android/helpers.rb:170:in block in fingerprint_from_apk' from C:/Ruby23-x64/lib/ruby/2.3.0/tmpdir.rb:89:inmktmpdir'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/calabash-android-0.9.6/lib/calabash-android/helpers.rb:169:in fingerprint_from_apk' from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/calabash-android-0.9.6/bin/calabash-android-build.rb:2:incalabash_build'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/calabash-android-0.9.6/lib/calabash-android/helpers.rb:107:in build_test_server_if_needed' from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/calabash-android-0.9.6/bin/calabash-android-run.rb:16:incalabash_run'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/calabash-android-0.9.6/bin/calabash-android:86:in <top (required)>' from C:/Ruby23-x64/bin/calabash-android:22:inload'
from C:/Ruby23-x64/bin/calabash-android:22:in
If you do not have debug.keystore file create it bu the following command, you need keytool which is in JAVA_HOME/bin:
keytool -genkey -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android -keyalg RSA -keysize 2048 -validity 10000 -dname "CN=Android Debug,O=Android,C=US"
Then run the calabash-android setup to assign this debug.keystore:
$ calabash-android setup
Please enter keystore information to use a custom keystore instead of the default
Please enter keystore location
...

How do you sign a mono for android application

I am attempting to add google map functionality to my mono for android application by following these instructions.
I have created a public.keystore and I am trying to use this keystore to sign the application by following these instructions, which I do not find explicit enough.
1) I gather I must add the following block into the csproj file. Is this correct?
<PropertyGroup>
<AndroidKeyStore>True</AndroidKeyStore>
<AndroidSigningKeyStore>public.keystore</AndroidSigningKeyStore>
<AndroidSigningStorePass>public</AndroidSigningStorePass>
<AndroidSigningKeyAlias>public</AndroidSigningKeyAlias>
<AndroidSigningKeyPass>public</AndroidSigningKeyPass>
</PropertyGroup>
2) What is the correct location of the public.keystore file?
I completely failed to register that there was full sample solution, as part of the instructions I was trying to follow that, that answered my questions.
I am a giddy goat.
1) You should, but I don't know if you must. If you do then you may need to change some of the values.
Consider a keystore that is created by the command:
keytool.exe -genkey -v -alias public -keyalg RSA -keysize 2048 -validity 10000 -keystore public.keystore
Then:
<AndroidSigningKeyStore>public.keystore</AndroidSigningKeyStore>
Defines the filename of the keystore ie. public.keystore
<AndroidSigningKeyAlias>public</AndroidSigningKeyAlias>
Is the alias of the key within the keysotre that you want to use. ie. public
<AndroidSigningStorePass>public</AndroidSigningStorePass>
Is the keystore's password. This will be the first password that you were prompted for.
<AndroidSigningKeyPass>public</AndroidSigningKeyPass>
Is the key's password. This will be the second password that you were prompted for.
References
http://developer.android.com/guide/publishing/app-signing.html#cert
http://android.xamarin.com/Documentation/Build_Process#Signing
2) You can place public.keystore in the root of the project, but you don't have to add it to the solution.
To location of the keystore file is defined by the following element from Question 1:
<AndroidSigningKeyStore>public.keystore</AndroidSigningKeyStore>
I am using command file to sign the package.
"C:\Program Files\Java\jdk1.6.0_25\bin\jarsigner.exe" -verbose -keystore key.keystore myapplication.apk keyalias
"C:\Program Files\Android\android-sdk\tools\zipalign.exe" -v 4 myapplication.apk myapplication-Signed.apk

Resources