×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Nov 2012
    Posts
    2

    midlet nokia 40, HttpsConnection did not work, Certificate failed verification

    Hi all,
    i created a midlet on nokia s40, use HttpsConnection to connect the server, but i got error Certificate failed verification.
    i just write the code like the document of nokia help, but it failed.
    void getViaHttpsConnection(String url)
    throws CertificateException, IOException {
    HttpsConnection c = null;
    InputStream is = null;
    try {
    c = (HttpsConnection)Connector.open(url);

    // Getting the InputStream ensures that the connection
    // is opened (if it was not already handled by
    // Connector.open()) and the SSL handshake is exchanged,
    // and the HTTP response headers are read.
    // These are stored until requested.
    is = c.openDataInputStream();

    if c.getResponseCode() == HttpConnection.HTTP_OK) {///////////exception happened at this line getResponseCode() function
    // Get the length and process the data
    int len = (int)c.getLength();
    if (len > 0) {
    byte[] data = new byte[len];
    int actual = is.readFully(data);
    ...
    } else {
    int ch;
    while ((ch = is.read()) != -1) {
    ...
    }
    }
    } else {
    ...
    }
    } finally {
    if (is != null)
    is.close();
    if (c != null)
    c.close();
    }
    }
    i try to add con.setRequestProperty("Content-Length",
    Integer.toString(url.length()));
    con.setRequestProperty("Content-Type", "text/html");
    but, i still got this error.

    i download an example for https, MIDP_2_0_Introduction_to_Secure_MIDlet_Communication_v1_0, but it failed too.

    who can tell me how to use httpsconnection? what property do i lost?
    who can give me a https example that can work?

    thank you all.

  2. #2
    Registered User
    Join Date
    Nov 2012
    Posts
    2

    Re: midlet nokia 40, HttpsConnection did not work, Certificate failed verification

    i can not open my https link, but the web browser on emulator can open my https link, does web browser not use the HttpsConnection class? must I encode the https link?

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

    Re: midlet nokia 40, HttpsConnection did not work, Certificate failed verification

    For HTTPS Connection to work, you need to sign the midlet with a valid 3rd party certificate like verisign and server should have a valid 3rd party SSL certificate.
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

  4. #4
    Nokia Developer Champion
    Join Date
    Mar 2003
    Posts
    4,104
    In J2ME, code signing is not required for HTTPS (or using HttpsConnection class). Otherwise you would get an exception of the type ‘SecurityException’.

    If the same server and certificate works in the internal web-browser, than you found a bug. However, you have to use an old Nokia Series 40 phone which do not use that new proxy-browser. The proxy-browser has its own list of known authorities, placed on a server at Nokia facilities. HttpsConnection and the old web-browser use the certificate authority list stored within your Nokia device. You are able to extend this list, however, it is much easer to use a well-known authority. Does this help?

Similar Threads

  1. Nokia 5310 XpressMusic: VERIFICATION FAILED: certificate failed verification
    By sandypop in forum Mobile Java Networking & Messaging & Security
    Replies: 4
    Last Post: 2012-02-17, 21:44
  2. HttpsConnection: Certificate failed verification
    By msowka in forum Mobile Java Networking & Messaging & Security
    Replies: 12
    Last Post: 2010-07-13, 17:38
  3. HttpsConnection doesn't work with polish
    By stefan.herold in forum Mobile Java Networking & Messaging & Security
    Replies: 6
    Last Post: 2009-06-04, 15:35
  4. Failed MIDlet install with VeriSign certificate
    By chgru in forum Mobile Java Networking & Messaging & Security
    Replies: 14
    Last Post: 2006-06-06, 16:57

Posting Permissions

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