Eclipse update site - how to sign jars? - eclipse

I have a few Eclipse plugins that are part of a feature. We would like to apply code signing to these plugins when the update site is updated.
I can see the JAR Signing tab when exporting an individual plugin, but I can't see anything similar in my update site project settings.
Also, the tutorials that I have read are using self-signed certificates. Can anyone point me towards instructions for using Verisign certificates (i.e. *.pfx files)?
Can anyone help?
Thanks,
Alan
Edit: I have marked Kane's response as the answer because it is very similar to the steps that I took and was an inspiration. I actually followed these instructions to sign the jars because it was based on pfx files: https://support.comodo.com/index.php?_m=knowledgebase&_a=viewarticle&kbarticleid=1072
Step 1: Run the following command to view details about the certificate (substituting the filename with your own):
keytool -list -v -storetype pkcs12 -keystore [Filename].pfx
Step 2: Scroll to the top of the output and take a note of the Alias name value.
Step 3: Sign each jar file using the following command (substituting the filenames and alias name for your own):
jarsigner -storetype pkcs12 -keystore [Filename].pfx [Filename].jar "[AliasName]"
I now need to come up with a way of managing / automating the process.

Update site project doesn't provide such capability to sign the jars. Signing jars is a pure java concept, you could use the signtool from JDK to do it.
If you want to sign you jars via using the certificate for Windows code signing, you could refer to this blog post.
In my successful experience, I convert pfx to JKS format certificate firstly, then call below command in ant,
<signjar sigfile="MyCompany" alias="${sign.alias}" keystore="${sign.keystore}" storepass="${sign.storepass}" keypass="${sign.keypass}" tsaurl="https://timestamp.geotrust.com/tsa" preservelastmodified="true">

Related

Facing Eclipse Marketplace Error after installing JDK 19

I have updated java to JDK 19 and when I try opening Eclipse Marketspace i am getting below error,
MarketplaceDiscoveryStrategy failed with an error
Cannot complete request to https://marketplace.eclipse.org/api/p?client=org.eclipse.epp.mpc.core&client.version=1.6.4.v20180214-1810&os=win32&ws=win32&nl=en_US&java.version=1.8.0_211&product=org.eclipse.epp.package.java.product&product.version=4.7.3.M20180330-0640&runtime.version=3.13.0.v20170207-1030&platform.version=4.7.3.v20180330-0640: Unable to read repository at https://marketplace.eclipse.org/api/p?client=org.eclipse.epp.mpc.core&client.version=1.6.4.v20180214-1810&os=win32&ws=win32&nl=en_US&java.version=1.8.0_211&product=org.eclipse.epp.package.java.product&product.version=4.7.3.M20180330-0640&runtime.version=3.13.0.v20170207-1030&platform.version=4.7.3.v20180330-0640.
I wanted to Install testNg so I tried adding the certificate as follows and made it trust, Still facing the same issue.
keytool -import -alias TestNg -keystore "C:\Program Files\Java\jdk-19\lib\security\cacerts" -file TestNg.cer
I get below error,
Unable to read repository at https://dl.bintray.com/testng-team/testng-eclipse-release/content.xml.
Unable to read repository at https://dl.bintray.com/testng-team/testng-eclipse-release/content.xml.
sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Am I missing anything, I don't see a JRE for JDK is that I am missing?
After exploring few I found a solution for this,
The reason behind the error was:
Our cooperate firewall (ZScalar) prevent these additional steps, and install attempts will fail with the below messages:
Unable to read repository at https://dl.bintray.com/testng-team/testng-eclipse-release/content.xml. Unable to read repository at https://dl.bintray.com/testng-team/testng-eclipse-release/content.xml. sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target.
Java did not recognize the root certificate authority (CA).
How to fix this?
There are two ways to fix this:
Admin team has to reconfigure the firewall to allow Java access to the certificate sites.(They did not agreed with this, so proceeded with below way).
To verify the root certificates, determine where the cacerts file is located.
Cacerts file is available in eclipse jre folder. For example
C:\Eclipse 2022 09\eclipse-java-2022-09-R-win32-x86_64\eclipse\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.4.v20220903-1038\jre\lib\security\cacerts
Now the certificate for the software’s needs to be added to this cacerts file. Eclipse marketplace itself was not opening for me. So on browser I pinged the below link,
https://marketplace.eclipse.org/
Click on the HTTPS certificate chain and navigate the certificate hierarchy. At the top there should be a Primary Root CA. This could be missing from my java cacerts file. Export the certificate and saved in my computer. Now imported to cacerts file.
Open cmd where the certificate is expoted. Execute below command.
keytool -import -alias MarketPlace -keystore "C:\Eclipse 2022 09\eclipse-java-2022-09-R-win32-x86_64\eclipse\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.4.v20220903-1038\jre\lib\security\cacerts" -file ZscalerRootCAMP.der
Here ZscalerRootCAMP.der is the certificate exported for Eclipse market place.
Restart eclipse, open Eclipse marketplace and now I am able to install software's.

You uploaded an APK that is signed with a different certificate to your previous APKs. You must use the same certificate [duplicate]

I had uploaded my app to Google Play (back when it was called Android Market) some time ago.
Today I updated the app, but I had deleted the previous keystore and created a new one.
When uploading, it says the APK must be signed with the same certificates as the previous version:
Upload failed
You uploaded an APK that is signed with a different certificate to your previous APKs. You must use the same certificate.
Your existing APKs are signed with the certificate(s) with fingerprint(s):
[ SHA1: 89:2F:11:FE:CE:D6:CC:DF:65:E7:76:3E:DD:A7:96:4F:84:DD:BA:33 ]
and the certificate(s) used to sign the APK you uploaded have fingerprint(s):
[ SHA1: 20:26:F4:C1:DF:0F:2B:D9:46:03:FF:AB:07:B1:28:7B:9C:75:44:CC ]
But I don't have this certificate, and don't want to delete and re-publish the application, because it has active users.
What can I do to sign my app with new certificate?
Nothing. Read the documentation: Publishing Updates on Android Market
Before uploading the updated application, be sure that you have incremented the android:versionCode and android:versionName attributes in the element of the manifest file. Also, the package name must be the same and the .apk must be signed with the same private key. If the package name and signing certificate do not match those of the existing version, Market will consider it a new application and will not offer it to users as an update.
Did you sign with the debug key by mistake?
Google Play does not allow you to publish an app signed with your debug keystore. If you try to upload such an APK, Google Play will fail with the message "You uploaded an APK that was signed in debug mode. You need to sign your APK in release mode."
However, if you try to upload an update which is signed with the debug keystore, you will not see this message; Google Play will display the message shown in the question, referring to SHA1 fingerprints.
So firstly, check whether you signed the app with your debug key by mistake.
How do I check which signing keys were used?
Gather the information from the APK
You can check which certificates the original APK and update APK were signed with by using these commands, using the Java keytool:
keytool -printcert -jarfile original.apk
keytool -printcert -jarfile update.apk
This shows you detailed information about the how an APK was signed, for example:
Owner: CN=My App, O=My Company, L=Somewhere, C=DE
Issuer: CN=My App, O=My Company, L=Somewhere, C=DE
Serial number: 4790b086
Valid from: Mon Nov 11 15:01:28 GMT 2013 until: Fri Mar 29 16:01:28 BST 2041
Certificate fingerprints:
MD5: A3:2E:67:AF:74:3A:BD:DD:A2:A9:0D:CA:6C:D4:AF:20
SHA1: A6:E7:CE:64:17:45:0F:B4:C7:FC:76:43:90:04:DC:A7:84:EF:33:E9
SHA256: FB:6C:59:9E:B4:58:E3:62:AD:81:42:...:09:FC:BC:FE:E7:40:53:C3:D8:14:4F
Signature algorithm name: SHA256withRSA
Version: 3
The important parts to note here — for each APK — are the SHA1 fingerprint value, the Owner identity value, and the Valid from/until dates.
If that keytool command doesn't work (the -jarfile option requires Java 7), you can get more basic information via the jarsigner command:
jarsigner -verify -verbose:summary -certs original.apk
jarsigner -verify -verbose:summary -certs update.apk
This unfortunately does not show the SHA1 fingerprint, but does show the X.509 owner identity, along with the certificate expiry dates. For example:
sm 4642892 Thu Apr 17 10:57:44 CEST 2014 classes.dex (and 412 more)
X.509, CN=My App, O=My Company, L=Somewhere, C=DE
[certificate is valid from 11/11/13 12:12 to 29/03/41 12:12]
[CertPath not validated: Path does not chain with any of the trust anchors]
You can ignore any "CertPath not validated" message, along with warnings about certificate chains or timestamps; they're not relevant in this case.
Compare the Owner, SHA1 and Expiry values between the APKs
If the Owner/X.509 identity value is CN=Android Debug, O=Android, C=US, then you have signed the APK with your debug key, not the original release key
If the SHA1 fingerprint value is different between the original and update APKs, then you did not use the same signing key for both APKs
If the Owner/X.509 identity values are different, or the certificate expiry dates differ between the two APKs, then you did not use the same signing key for both APKs
Note that even if the Owner/X.509 values are identical between the two certificates, this doesn't mean that the certificates are identical — if anything else does not match — such as the fingerprint values — then the certificates are different.
Search for the original keystore, check backups
If the two APKs have different certificate information, then you must find the original keystore, i.e. the file with the first SHA1 fingerprint value that Google Play (or keytool) told you.
Search through all the keystore files you can find on your computer, and in any backups you have, until you have the one with the correct SHA1 fingerprint:
keytool -list -keystore my-release.keystore
Just press Enter if prompted for the password — you don't necessarily have to enter it if you just want to quickly check the SHA1 value.
I can't find the original keystore anywhere
If you cannot find the original keystore, you will never be able to publish any updates to this particular app.
Android mentions this explicitly on the Signing Your Application page:
Warning: Keep your keystore and private key in a safe and secure place, and ensure that you have secure backups of them. If you publish an app to Google Play and then lose the key with which you signed your app, you will not be able to publish any updates to your app, since you must always sign all versions of your app with the same key.
After the first release of an APK, all subsequent releases must be signed with the exact same key.
Can I extract the original signing key from the original APK?
No. This is not possible. The APK only contains public information, and not your private key information.
Can I migrate to a new signing key?
No. Even if you do find the original, you can't sign an APK with key A, then sign the next update with both keys A and B, then sign the next update after that with only key B.
Signing an APK (or any JAR file) with multiple keys is technically possible, but Google Play no longer accepts APKs with multiple signatures.
Attempting to do so will result in the message "Your APK has been signed with multiple certificates. Please only sign it with one certificate and upload it again."
What can I do?
You will have to build your app with a new application ID (e.g. change from "com.example.myapp" to "com.example.myapp2") and create a brand new listing on Google Play.
Possibly you will also have to change your code so that people can install the new app even if they have the old app installed, e.g. you need to make sure that you don't have conflicting content providers.
You will lose your existing install base, reviews etc., and will have to find a way to get your existing customers to uninstall the old app and install the new version.
Again, ensure you have secure backups of the keystore and password(s) you use for this version.
Nothing - Google says it clearly that the application is identified by the keys used to sign it. Consequently if you've lost the keys, you need to create a new application.
I just had this occur out of the clear blue. I really do not think I changed anything.
However, Build => Clean Project fixed it.
Today i faced same issue, unfortunately, i was having two aliases in my keystore file.
Here i get the answer for that question . After searching for too long finally i get to crack the key and password for this . I forget my key and alias also the jks file but fortunately i know the bunch of password what i had put in it . but finding correct combinations for that was toughest task for me .
Solution -
Download this - Keytool IUI version 2.4.1 plugin
the window will pop up now it show the alias name ..if you jks file is correct ..
right click on alias and hit "view certificates chain "..
it will show the SHA1 Key .. match this key with tha key you get while you was uploading the apk in google app store ...
if it match then you are with the right jks file and alias ..
now lucky i have bunch of password to match ..
now go to this scrren put the same jks path .. and password(among the password you have ) put any path in "Certificate file"
if the screen shows any error then password is not matching .. if it doesn't show any error then it means you are with correct jks file . correct alias and password()
now with that you can upload your apk in play store :)
I highly recommend Keystore Explorer (https://keystore-explorer.org/) which lets you access your keystore without having to upload it to Google Play. This way you can troubleshoot whether you are entering your password incorrectly.
If you have previous apk file with you(backup) then use jarSigner to extract certificate from that that apk, then use that key or use keytool to clone that certificate, may be that will help...
Helpful links are jarsigner docs and keytool docs.
Please check your android/app/build.gradle file for
android{
...
buildTypes {
release {
// signingConfig signingConfigs.debug
signingConfig signingConfigs.release
}
}
...
}
before releasing the appbundle, It should have the signingConfig signingConfigs.release this line enabled instead of signingConfig signingConfigs.debug this line.
I made this silly mistake.
I was testing my updated app on other devices by releasing it with the debug sign in config and when I was ready to publish the update I didn't change the config and released the bundle which had the debug config.
After scratching my head for around an hour I realized that I had this debug config all the time then I changed it to release mode now the problem is solved.
I had faced this issue recently, after trying different ways to sign in like enable V1 Or V2, signed in by changing alias name and last come to know that I am using wrong key store file
You can use new feature Google play app signing to generate a new key file .
After May 2017 Google play store add a new feature on Play store and
It’s Good News For Android Developers.
From this feature, Developer can update their app or Apk who lost a KeyStore file.
you need to enable google play app signing on play store console.
https://support.google.com/googleplay/android-developer/answer/7384423?hl=en
http://www.geekcodehub.com/2018/05/23/keystore-lost-in-android/
My [silly] mistake was that i used app-debug.apk file instead of app-release.apk file.
You need to to choose "release" in "Build Variants" frame when you generate signed APK.
The app-release.apk file should be located under "app\release" folder in your project root.
What worked for me: I realized I had previously uploaded an .aab file and I was now trying to upload .apk file. I just needed to check Build App Bundle (Google Play) on build settings
For Flutter Developers:
You need to reverify key.properties file.
android/key.properties
Click on the Select Sign-in key(locate top of AppBundle text) and select Release signed by google

Extract certificate (.cer) from installer programmatically

I am building an installer and need to extract the .cer so that it can be added to trusted publisher, similar to this question/answer.
https://superuser.com/a/464233
I've managed to do that and everything works fine. Can the "Copy to file" from within Digital Signatures tab be automated using PowerShell or something similar ?
You can run Get-AuthenticodeSignature cmdlet to retrieve authenticode signing certificate from MSI.

Need to export a Symantec Code signing certificate as .pfx

I need to export a Symantec Code signing certificate for signing .xap as .pfx. The steps mentioned on official website state All Tasks>Export as .pfx but the option is grayed out. For pvk2pfx.exe we need a .pvk which is not provided. I have only a .cer file wwhich ii want to concert into a .pfx file with a password. Kindly suggest me the steps and suitable tool!
The .cer file was without the key. A small key icon appears next to the certificate name in microsoft certificate snap-in. Regenerating the certificates did the task!

How to Import Reconfigured apk File from Amazon Appstore into Eclipse for Signing

Amazon App Store (appstore) - Marketplace requires you to upload unsigned apk files. They then reconfigure and add their own coding. They then ask you to download that reconfigured file, sign it, then re-upload it to their site.
I'm having a heck of a time trying to import that reconfigured file into Eclipse for signing. Do I use the IMPORT option? If so, what specific steps? Or do I use the Terminal to sign?
I tried importing the new file the same way I imported my original project (using Wizard: Android>Android Project...) but that won't work for the new file.
Any suggestions or workarounds would be appreciated.
PS I found a great site that helps with eclipse and installing apks. But it didn't answer this question.
http://www.satyakomatineni.com/akc/display?url=displaynoteimpurl&ownerUserId=satya&reportId=3279
The ADT plugins for Eclipse can't import an APK to sign it, they can only export a signed (or unsigned) APK. But these instructions from the Android Developers site should help you get on your way: http://developer.android.com/guide/publishing/app-signing.html#signapp
You don't need to import the .apk file back into Eclipse, but can sign it from command line. In fact, Eclipse invokes this same procedure behind the scenes when it signs your binary.
In the samples below, replace the AppName with your application's name. The first step (to generate the keystore file) you will do only once when you setup your project, and the other 2 steps -- every time you need to sign the app. I hope that answers your question.
:: Generate a keystore file
cd "c:\Program Files (x86)\Java\jdk1.6.0_21\bin"
keytool.exe -genkey -v -keystore AppName.keystore -alias AppName -keyalg RSA -keysize 2048 -validity 10000
:: Sign the .apk file
cd "c:\Program Files\Java\jdk1.6.0_29\bin"
jarsigner.exe" -keystore AppName.keystore AppName.apk AppName
:: Zip align the .apk file and copy it to the install folder
cd "c:\Program Files (x86)\android\android-sdk\tools"
zipalign.exe" -f -v 4 AppName.apk install\AppName.apk