A simple question with a fairly complicated answer:
How do you sign a Java Midlet so you can load it onto a mobile phone with less security prompts?
A simple question with a fairly complicated answer:
How do you sign a Java Midlet so you can load it onto a mobile phone with less security prompts?
Get required software
Import an existing certificate (if you have one)
keytool -import -alias {myalias} -file {mycertificate}
(I haven't been able to test this since I don't have a proper certificate)keytool -list
to see your new certificatekeytool -export -alias {myalias} -file mycertificate.crt
Create and import a new (test) certificate
keytool -genkey -alias {myalias} -keyalg RSA -validity 365
keytool -list
to see your new certificatekeytool -export -alias {myalias} -file mycertificate.crt
C:\j2sdk1.4.2_08\bin>keytool -genkey -alias company -keyalg RSA -validity 365
Enter keystore password: password
What is your first and last name? [Unknown]: My Name
What is the name of your organizational unit? [Unknown]: company
What is the name of your organization? [Unknown]: company
What is the name of your City or Locality? [Unknown]: location
What is the name of your State or Province? [Unknown]: location2
What is the two-letter country code for this unit? [Unknown]: GB
Is CN=My Name, OU=company, O=company, L=location, ST=location2, C=GB correct? [no]: yes
Enter key password for (RETURN if same as keystore password):
Build and package the application
javac
to build your MIDlet paying special attention to your classpath and bootclasspath options (otherwise preverification will fail). I also set target to 1.1 and source to 1.3MIDlet-Jar-URL
Sign the application
jarsigner
jarsigner -keystore {mykeystore} -storepass (mypassword} {myjar} {myalias}
MIDlet-Jar-Size
in your JADJadTool.jar
from the WTKjava -jar JadTool.jar -addcert -alias {myalias} -storepass {mypassword} -keystore {mykeystore} -inputjad {myinputjad} -outputjad {myoutputjad}
JadTool.jar
java -jar JadTool.jar -addjarsig -alias {myalias} -jarfile {myjar} -storepass {mypassword} -keypass {mypassword} -keystore {mykeystore} -inputjad {myinputjad} -outputjad {myoutputjad}
Deployment
Installing the Certificate on the phone
Common Problems
MIDlet-Permissions
can cause problems but it seems ok to me on Nokia 6680/6630/6230i (could be firmware dependent?)MIDlet-Permissions
attribute is the cause of a lot of problems (especially since the documentation is often wrong/missing or different depending on the phone), try leaving it out first and add permissions in one at a time. Some phones will complain about permissions they don't support, some will ignore themTrust Domains
Unresolved Problems
Sample JAD
MIDlet-Jar-URL: MyApp.jar
MIDlet-Jar-Size: 201365
MIDlet-Name: MyApp
MIDlet-Vendor: EC1M
MicroEdition-Profile: MIDP-2.0
MicroEdition-Configuration: CLDC-1.1
MIDlet-Icon: logo.png
MIDlet-Push-1: sms://:6553,net.ec1m.MyApp.midp.MyAppMIDlet,*
MIDlet-Description: MyApp MIDlet
MIDlet-Permissions: javax.microedition.io.PushRegistry,javax.microedition.io.Connector.sms...
MIDlet-Version: 1.0.67 MIDlet-1: MyApp, logo.png,net.ec1m.MyApp.midp.MyAppMIDlet
MIDlet-Certificate-1-1: MIICODCCAaECBEKqpfswDQYJKoZIhvcNAQEEBQAwYz...=
MIDlet-Jar-RSA-SHA1: EUsAch/.../hEZOsJsiCjBOhNs/3FSw4=
Sample Manifest
Manifest-Version: 1.0 MIDlet-Name: MyApp Created-By: 1.4.2_05-b04 (Sun Microsystems Inc.) MIDlet-Push-1: sms://:6553,net.ec1m.MyApp.midp.MyAppMIDlet,* MIDlet-1: MyApp, logo.png, net.ec1m.MyApp.midp.MyAppMIDlet MicroEdition-Configuration: CLDC-1.1 Ant-Version: Apache Ant 1.6.2 MIDlet-Icon: logo.png MIDlet-Vendor: EC1M MIDlet-Permissions: javax.microedition... MIDlet-Version: 1.0.67 MicroEdition-Profile: MIDP-2.0 MIDlet-Description: MyApp MIDlet
Sample Ant Build File I've put our EC1M ant build file up on our website to (hopefully) make all this a little easier for you. Other Resources This FAQ on the Nokia Forum is worth a read.
Nokia Asha 302
) but when I go to Certificate Management
the Applications Signing
option is greyed out so I get the error Certificate not on device or SIM
when I try to open it. How can I enable it? I'm desperate! I'm trying to sign a self-made application for 2 days and I can't get it working! :( –
Arbuckle Step1: Create CSR request which may be raised by
1) Creating keystore and using that generate CSR file.
2) Perform steps given by certificate authority and download CSR and private key files.
Step2: Give your information to certificate authority for verification.
Step3: You will be provided a certificate for code signing.
Step4: You need to down load intermediate certificate along with root certificate.
Step5: Now you will be having your_domain_name.crt, IntCertCA.crt, TrustedRoot.crt
Now you need to create a chained certificate by combining all above certificates.
1) Open a text editor (such as wordpad) and paste the entire body of each certificate into one text file in the following order:
The Primary Certificate - your_domain_name.crt
The Intermediate Certificate - IntCertCA.crt
The Root Certificate - TrustedRoot.crt
Make sure to include the beginning and end tags on each certificate. The result should look like this:
-----BEGIN CERTIFICATE-----
(Your Primary SSL certificate: your_domain_name.crt)
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
(Your Intermediate certificate: IntCertCA.crt)
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
(Your Root certificate: TrustedRoot.crt)
-----END CERTIFICATE-----
Save the combined file as your_domain_name.pem. The .pem file is now ready to use.
Step6: Import private key into your your_domain_name.pem
openssl pkcs12 -export -in your_domain_name.pem -inkey your_private_key.key -out output_file_name.p12 -name your_alias
NOTE: PLEASE REMOVE \ FROM FOLLOWING COMMANDS AND EXECUTE ( \ IS BASICALLY COMMAND CONTINUETY )
Step7: Create keystore from output_file_name.p12
keytool -importkeystore \
-deststorepass changeit -destkeypass changeit -destkeystore your_domain_keystore.ks \
-srckeystore output_file_name.p12 -srcstoretype PKCS12 -srcstorepass your_store_password \
-alias your_alias
Step8: NOTE: PLEASE TAKE BACKUP OF YOUR JAD FILE BEFORE TRIGGERING FOLLOWING COMMANDS.
Add your certificates to your your_midlet_name.jad file.
java -jar JadTool.jar -addcert -alias your_alias \
-storepass your_store_password \
-keystore your_domain_keystore.ks \
-inputjad your_midlet_name.jad -outputjad your_midlet_name.jad
Step9: NOTE: PLEASE TAKE BACKUP OF YOUR JAD FILE BEFORE TRIGGERING FOLLOWING COMMANDS.
Sign your midlet, also use your_midlet_name.jad file generated from Step8.
java -jar JadTool.jar -addjarsig \
-alias your_store_password \
-storepass your_store_password \
-keypass your_store_password \
-keystore your_domain_keystore.ks \
-inputjad your_midlet_name.jad -outputjad your_midlet_name.jad
© 2022 - 2024 — McMap. All rights reserved.