×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Regular Contributor
    Join Date
    Jan 2010
    Posts
    52

    Java code signing

    Hey guys,

    I've developed a MIDlet for Nokia 6212 (S40). I purchased a certificate from Thawte using this process:

    I ran this: keytool.exe -genkey -alias RCH -keyalg RSA -keystore c:\keystore.sks
    I was asked all there questions, after which I received a CSR which I sent to Thawte.
    I got the signed data from Thawte that starts with:
    -----BEGIN PKCS #7 SIGNED DATA-----
    I took all this data and saved it in a text file (signeddata.txt).
    How do I import this data into the keystore, how do I sign my MIDlet and how do I import the certificate into the device?

    Thanks!

  2. #2
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,085

    Re: Java code signing

    Try using the following command keytool -import -alias {myalias} -file {mycertificate}
    then Run keytool -list to see your new certificate

    Then use midlet sigining tool - to sign the Midlet with this certified keystore.

    This root certificate will be already installed in the device with the firmware, you cannot add if its not their. You will need use the supported one only.

    thanks,
    ~Amitabh
    Last edited by im2amit; 2010-04-10 at 15:48.

  3. #3
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Java code signing

    Quote Originally Posted by giaviv View Post
    how do I sign my MIDlet
    The wiki has many articles about signing - start with this one - it links to several others.

    Quote Originally Posted by giaviv View Post
    and how do I import the certificate into the device?
    You cannot. The device must already have the Thawte root code signing certificate factory installed.

    Graham.

  4. #4
    Regular Contributor
    Join Date
    May 2007
    Location
    India
    Posts
    208

    Re: Java code signing

    Quote Originally Posted by giaviv View Post
    ...how do I import the certificate into the device?
    You cannot.

  5. #5
    Regular Contributor
    Join Date
    Jan 2010
    Posts
    52

    Re: Java code signing

    Hey guys,

    Thanks a lot for the reply. I was able to sign the MIDLet and install it on the phone.
    My MIDLet sends a text message when it loads using the following code:

    message_connection = (MessageConnection)Connector.open("sms://1323123123:0"); // the actual phone number is different of course
    TextMessage text_message = (TextMessage)message_connection.newMessage(MessageConnection.TEXT_MESSAGE, "sms://1323123123:0");
    text_message.setPayloadText("test 123");
    m_message_connection.send(text_message);

    When my MIDlet wasn't signed, I was prompted to allow this text message to be sent every time the MIDLet tried to send the message.
    I signed the application in order to allow the MIDLet to send text messages without the need of user intervention.
    When I installed the same MIDLet on the phone, only this time it was signed, a "Connection is not allowed" exception is thrown at the first line of code above. I tried playing with the Application Access settings for messaging and changed it to all available options (ask every time, always allowed etc.) and it always throws the same exception while trying to connect. I'm using a Nokia 6212 S40 device. What can I do to solve this? I tried looking around the phones security settings but I couldn't find anything relevant to this..

    Thanks!

  6. #6
    Regular Contributor
    Join Date
    May 2007
    Location
    India
    Posts
    208

    Re: Java code signing

    Quote Originally Posted by giaviv View Post
    Hey guys,

    Thanks a lot for the reply. I was able to sign the MIDLet and install it on the phone.
    My MIDLet sends a text message when it loads using the following code:

    message_connection = (MessageConnection)Connector.open("sms://1323123123:0"); // the actual phone number is different of course
    TextMessage text_message = (TextMessage)message_connection.newMessage(MessageConnection.TEXT_MESSAGE, "sms://1323123123:0");
    text_message.setPayloadText("test 123");
    m_message_connection.send(text_message);

    When my MIDlet wasn't signed, I was prompted to allow this text message to be sent every time the MIDLet tried to send the message.
    I signed the application in order to allow the MIDLet to send text messages without the need of user intervention.
    When I installed the same MIDLet on the phone, only this time it was signed, a "Connection is not allowed" exception is thrown at the first line of code above. I tried playing with the Application Access settings for messaging and changed it to all available options (ask every time, always allowed etc.) and it always throws the same exception while trying to connect. I'm using a Nokia 6212 S40 device. What can I do to solve this? I tried looking around the phones security settings but I couldn't find anything relevant to this..

    Thanks!
    Have you tried any other application on the same phone to see if connection works at all?

  7. #7
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Java code signing

    Once your app is signed, you need to request access to restricted APIs. In your case, add:

    Code:
    MIDlet-Permissions: javax.microedition.io.Connector.sms
    MIDlet-Permissions: javax.wireless.messaging.sms.send
    to your MANIFEST and your JAD. Your IDE might have an option for doing this for you (look for application properties, application descriptor editor, security settings, something like that).

    Using "MIDlet-Permissions" will prevent your app from installing if the permission is not available. Change them to "MIDlet-Permissions-Opt" if you want those permissions, but would rather have an exception at runtime than not installing at all.

    Graham.

  8. #8
    Regular Contributor
    Join Date
    Jan 2010
    Posts
    52

    Re: Java code signing

    Hey,

    Thanks again for the reply. I tried what you suggested (adding MIDlet-Permissions: javax.microedition.io.Connector.sms and MIDlet-Permissions: javax.wireless.messaging.sms.send) to my jad (I don't have a manifest - I'm using netbeans and all I have in my dist folder is my jar and my jad). The application does install, but I still get the connection not allowed exception like before. What else can I try?

    Thanks again!

  9. #9
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Java code signing

    They must be in your manifest... it's in your JAR, and your IDE is probably creating it for you. Since the manifest is in the JAR, it must be added before the JAR is signed. Your IDE should have an option for adding these - look for the application properties or application descriptor. I don't use NetBeans, so I can't tell you where to look.

    Graham.

Similar Threads

  1. Regarding Code Signing Process for JME Applications
    By sappy2nokia in forum Mobile Java Networking & Messaging & Security
    Replies: 3
    Last Post: 2010-01-12, 13:03
  2. Series 40 code signing issues with push registry
    By blackbuddha in forum Mobile Java Networking & Messaging & Security
    Replies: 5
    Last Post: 2009-05-21, 13:43
  3. Replies: 106
    Last Post: 2009-05-11, 05:53
  4. Code signing & OCSP
    By tiffani2k3 in forum Mobile Java General
    Replies: 2
    Last Post: 2007-03-09, 11:50
  5. Replies: 0
    Last Post: 2004-09-15, 11:46

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×