Recent Notes

Displaying keyword search results 1 - 11
Created by Dr. Xi on May 02, 2011 15:59:37    Last update: February 25, 2012 09:16:37
This code snippet gets the default keystore used by the Java keytool and displays the list of aliases along with the key type (certificate or private key). import java.io.File; import java.io.FileInputSt... The default keystore used by the above code is: $HOME/.keystore .
Created by freyo on August 31, 2011 15:49:54    Last update: August 31, 2011 15:49:54
Got this error while trying to build Android app: [apkbuilder] Creating AppInfo-debug-unaligned.ap... Solution: Delete the Android debug keystore: $ rm ~/.android/debug.keystore Build again: $ ant debug The new key is valid for 30 years (keystore password is 'android'): $ keytool -list -v -keystore ~/.android/debug.keys...
Created by freyo on August 04, 2011 14:50:32    Last update: August 04, 2011 14:50:32
Take these steps to automate Android APK signing with release key: Put the release key in the Java keystore, for example: /home/freyo/.keystore Create build.properties file with key.store and key.alias entries: key.store=/home/freyo/.keystore key.alias=andro... Build APK with ant release : $ ant release Buildfile: /home/freyo/AndroidApp...
Created by freyo on June 28, 2011 11:11:03    Last update: June 28, 2011 11:11:03
This exception occurs when trying to get a private key: PrivateKey privateKey = (PrivateKey) keyStore.getK... Stack trace: Exception in thread "main" java.security.Unrecover... which was caused by giving a wrong private key password. The solution is to correct the key password in your code, or change the password in the keystore to match that in your code: keytool -keypasswd -alias mykey -keypass oldpasswo...
Created by freyo on May 06, 2011 16:07:33    Last update: May 06, 2011 16:08:36
Private key: -----BEGIN PRIVATE KEY----- MIIEvAIBADANBgkqhki... Certificate: -----BEGIN CERTIFICATE----- MIIEqDCCA5CgAwIBAgI... Import the key pair to the debug keystore: $ cat platform.pem platform.x509.pem >platform-key...
Created by freyo on May 05, 2011 14:40:07    Last update: May 05, 2011 14:40:36
The Android debug key store is located at ${user.home}/.android . On Windows XP, this is: C:\Documents and Settings\<user>\.android\ . Keystore name, password, etc: Keystore name: "debug.keystore" Keystore password: "android" Key alias: "androiddebugkey" Key password: "android" CN: "CN=Android Debug,O=Android,C=US"
Created by freyo on April 20, 2011 12:50:09    Last update: April 20, 2011 12:50:09
To sign an Android APK from command line: Sign the APK with jarsigner (using default keystore, android-root is the alias of the signing key): $ jarsigner -signedjar HelloWorld-new.apk HelloWor... Verify signature (optional) $ jarsigner -verify -verbose -certs HelloWorld-new... Align the APK (must use -v 4 option): $ ~/android-sdk-linux_86/tools/zipalign -v 4 Hello...
Created by freyo on April 20, 2011 12:26:08    Last update: April 20, 2011 12:26:08
When you create a new key with Java keytool , it wraps the public key in a self signed certificate. You can generate a certificate signing request with the keytool -certreq command. After a certificate authority (CA) signs the certificate request, you can import the certificate received (a .crt file) back into the key store. Instead of using a CA, you can sign the certificate request with another key (with openssl, for example). If the certificate is not signed by a CA, you'll receive an error: $ keytool -import -alias android-root -file androi... To fix the problem, import the certificate of the signer: $ keytool -import -trustcacerts -file openssl.crt ... Import the certificate again (alias is the alias of the private key whose certificate was...
Created by freyo on February 23, 2011 13:38:23    Last update: February 23, 2011 13:38:23
The Java keytool utility does not support importing a private key directly from a file. But it does support merging a keystore with the -importkeystore command. So, for a private key generated with OpenSSL in PEM format, you first convert the PEM key into PKCS12 format , then merge the one-key PKCS12 store with the Java KeyStore: C:\>keytool -importkeystore -srckeystore openssl_c...
Created by Dr. Xi on January 29, 2009 00:01:02    Last update: February 04, 2011 14:57:40
Generate key valid for 10 years (3650 days). Since no -keystore option is given, the key is stored in the default keystore $HOME/.keystore . C:\tmp>keytool -genkey -keyalg rsa -alias myke... Create the applet jar: jar -cf myapplet.jar com/my/applet Sign jar: C:\tmp>jarsigner myapplet.jar mykey Enter Passp... Verify signature: C:\tmp>jarsigner -verify -verbose -certs myapplet....
Created by Dr. Xi on June 03, 2010 18:29:59    Last update: June 03, 2010 18:31:49
Generate a private key and store it in the keystore. The keystore file theKeyStore.jks will be created if it does not exist. The default keystore file is $HOME/.keystore if the -keystore option is not given. keytool -genkey -alias myjavakey -keyalg RSA -keys... Generate a private key and self-sign for 10 years. keytool -genkey -alias myjavakey -keyalg RSA -vali... List keys in the keystore. # short list keytool -list -keystore theKeyStor... Create a certificate signing request (CSR). keytool -certreq -alias myjavakey -keystore theKey... It seems that the Java keytool utility can't sign third party certificate signing requests (CSRs). We can use openssl to sign the certificate request created above. Generate signing private key with openssl. openssl genrsa -out openssl_ca.key -des 2048 Generate self-signed certificate valid for...