Wednesday, April 25, 2007

How to sign a J2ME midlet with a Verisign code signing certificate using EclipseME

Get a code signing certificate
This can be from Verisign. The certificates issued by Verisign have the special "feature" that they are issued by an intermediate certificate authority. The certificate of the intermediate CA is unknown to your phone and thus the signature verification fails :-(
The following steps describe one way to make it suceed.

Configuring Eclipse to sign your midlet

See also: http://eclipseme.org/docs/refSigning.html

- Open the project properties and select j2meCheck the box "sign midlet" and enter the path to your keystore and the alias of the key.

Up to here everything is well documented in various places in the web.
MIDP_2_0_Signed_MIDlet_Developers_Guide_v2_0_en.pdf.html
Chapter 4.3 talks about intermediate certificates.

Now for the not so well documented issues

- Open the jad file in Eclipse

Select the "optional properties" tab to enter the "midlet permissions".
In my example these are "javax.microedition.io.Connector.serversocket"

Now the essential bit. Open the user defined tab and create a new entry named "MIDlet-Certificate-1-2". The value is the intermediate certificate (in one line and without the "-----BEGIN CERTIFICATE-----" and the "-----END CERTIFICATE-----").


-----BEGIN CERTIFICATE-----
MIIEvzCCBCigAwIBAgIQQZGhWjl4389JZWY4HUx1wjANBgkqhkiG9w0BAQUFADBf
MQswCQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xNzA1BgNVBAsT
LkNsYXNzIDMgUHVibGljIFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkw
HhcNMDQwNzE2MDAwMDAwWhcNMTQwNzE1MjM1OTU5WjCBtDELMAkGA1UEBhMCVVMx
FzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVz
dCBOZXR3b3JrMTswOQYDVQQLEzJUZXJtcyBvZiB1c2UgYXQgaHR0cHM6Ly93d3cu
dmVyaXNpZ24uY29tL3JwYSAoYykwNDEuMCwGA1UEAxMlVmVyaVNpZ24gQ2xhc3Mg
MyBDb2RlIFNpZ25pbmcgMjAwNCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
AQoCggEBAL687rx+74Pr4DdP+wMQO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PkXVViroi8tLqQXWI
L2NVfR5UWpVZytk0gcBfXvZ6tQ==
-----END CERTIFICATE-----


In the Verisign case you can obtain the intermediate certificate from here: http://www.verisign.com/support/verisign-intermediate-ca/
code-signing-intermediate/index.html



The resulting jad file should look something like this:
MIDlet-1: ServerSocket,,ServerSocketTest
MIDlet-Certificate-1-1: MIIE1jCCA76gAwIBAgIQG5t/GM10hgvEMeYewFYfOzANBgkqhkiG9w0BAQUFADCBtDELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTswOQYDVQQLEzJUZXJtcyBvZiB1c2UgYXQgaHR0cHM6Ly93d3cudmVyaXNpZ24uY29tL3JwYSAoYykwNDEuMCwGA1UEAxMlVmVyaVNpZ24gQ2xhc3MgMyBDb2RlIFNpZ25pbmcgMjAwNCBDQTAeFw0wNzAzMTYwMDAwMDBaFw0wODAzMTUyMzU5NTlaMIGnMQswCQYDVQQGEwJERTEPMA0GA1UECBMGQmVybGluMQ8wDQYDVQQHEwZCZXJsaW4xKzApBgNVBAoUIlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHDAaBgNVBAsUE1N5c3RlbXMgSW50ZWdyYXRpb24xKzApBgNVBAMUIlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAK0FJv9g3xIFUFYMSZ7wfrX3N+X4UHlrWVDsdKQ3DJ2tXdnY9OaocSMp4lb5UqjPZxQvHUo5ogJs8jgSB2yp5OWH6DCYfIR6rxxuKI5evNhOwX3nuoyd5L/S2NmPHLig384XdPKjFBSjZUbOpWvofHMwcRvs380LdUe2K99hnuEHAgMBAAGjggFxMIIBbTAJBgNVHRMEAjAAMA4GA1UdDwEB/wQEAwIHgDBABgNVHR8EOTA3MDWgM6Axhi9odHRwOi8vQ1NDMy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3MDUGA1UECxMuQ2xhc3MgMyBQdWJsaWMgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eYIQcLrkHRDZKTS2OMp7A8y6vzANBgkqhkiG9w0BAQUFAAOBgQCuOhe4SntV+mRV7ECk7UlBkJmcibyvLh3KeCP5HBkPf+tovDLZiDje3D/TibQ/sYKW8aRauu0uJtPefAFuAAoApAaSEUgJQPkcGHlnIyTgu9XhUK4b9Q7d4C6BzYCjbFJPkXVViroi8tLqQXWIL2NVfR5UWpVZytk0gcBfXvZ6tQ==
MIDlet-Jar-RSA-SHA1: kR0z1GiL6cZ7D+cQSjVYpI2zT5IGpOGZ6FVEF2VnVOwwVm+aQywWZkKDxKB6IgoiCcnqCqD7fTAAyHhrMvcqzW5CHpJ3uvmwvXhTdKRhBRWtra4C0e+lzBSzmD6ET+8bZaweFjmp4uxzGzH/0YMFnJFzrzLcYa0R1jDz01xANG4=
MIDlet-Jar-Size: 4334
MIDlet-Jar-URL: ServerSocketTest.jar
MIDlet-Name: ServerSocket
MIDlet-Permissions: javax.microedition.io.Connector.serversocket
MIDlet-Vendor: T-Systems Enterprise Services GmbH
MIDlet-Version: 1.0.9
MicroEdition-Configuration: CLDC-1.1
MicroEdition-Profile: MIDP-2.0




Now signing your midlet should work and the phone should be able to verify the signature.

9 comments:

Anonymous said...

would u mind to send me the cerf of Versign? Since I am a poor university student in Hong Kong, and I am currently working for the final year project about J2ME

my email address:wichan@cs.hku.hk

Andre Pinto said...

Hy, this tutorial did not work for me. When I try to install the jad file (placed in the same folder jar file is) the phone launches a message "Operation failed".

Unknown said...

Hi Andre, please send more details to me by email.
a x e l @ n e n n k e r . d e
have fun,
Axel

Francis said...

I need a cert too T___T
my email is francispang@hotmail.com.

Can i have it also please. So expensive the certificate.

Unknown said...

Hi, me too require certificate, i have done the self-signed midlet. please send me the more info.

My Email: harshalpatil007@gmail.com

Unknown said...

dude... post your private key! ;-)

Artem Khojoyan said...

Are you guys crazy or what ? Author wrote an article to help you all and you better say "thank you", instead of asking him to send you a Verisign certificate which is not free ! Such kind of people just pisses me off ......... Are you from another planet or what ?

Gyan Bhatnagar said...

Hey artemius

I would like to know the procedure to get a certificate
could u pls tell me.. and what is the cost to get that?

Br Gyan

Unknown said...

http://www.thawte.com/code-signing/index.html
http://www.verisign.com/code-signing/index.html

Certum offered FREE certs to opensource projects in the past. I do not know whether they still do that: http://www.certum.eu/certum/cert,offer_code_signing.xml