Results 1 to 13 of 13

Thread: java https connection error

  1. #1
    Chillie in here j.o.s.h.1408's Avatar
    Join Date
    Dec 2005
    Location
    a place called home
    Posts
    8,545
    Thanks
    757
    Thanked
    256 times in 193 posts
    • j.o.s.h.1408's system
      • Motherboard:
      • ASUS P6T Delux
      • CPU:
      • Intel core i7 920 @ 3ghz
      • Memory:
      • 3GB DDR RAM
      • Storage:
      • 1TB Samsung F1, 500GB Seagate baracuda + 320gb Seagate PATA +150GB WD PATA
      • Graphics card(s):
      • EVGA 480GTX SC edition
      • PSU:
      • Seasonic M12 600W Module PSU FTW
      • Case:
      • Lian Li PC-A7010B (the rolls royce of pc cases)
      • Operating System:
      • vista ultimate edition and windows xp
      • Monitor(s):
      • 22inch 2005FPW dell monitor
      • Internet:
      • 24mb BE There Broadband

    java https connection error

    Hi i get the following exception thrown at me when trying to connect to a php server. the exception is:

    javax.microedition.pki.CertificateException: Certificate was issued by an unrecognized entity

    my code is below:

    Code:
      public void open()
        {
            try
            {
                server = (HttpsConnection) Connector.open(url);
                
                is = server.openInputStream();
                os = server.openOutputStream();
                Alert alert = new Alert ("Error");
                alert.setString("everything working fine");
                alert.setTimeout (3000);
                Display.getDisplay(root).setCurrent(alert);
            }
            catch(Exception e)
            {
                e.printStackTrace();
                String error = e.toString();
                Alert alert = new Alert ("Error");
                alert.setString("Error, " + e);
                alert.setTimeout (5000);
                Display.getDisplay(root).setCurrent(alert);
                    
                    
            }
        }

  2. #2
    Comfortably Numb directhex's Avatar
    Join Date
    Jul 2003
    Location
    /dev/urandom
    Posts
    17,074
    Thanks
    228
    Thanked
    1,027 times in 678 posts
    • directhex's system
      • Motherboard:
      • Asus ROG Strix B550-I Gaming
      • CPU:
      • Ryzen 5900x
      • Memory:
      • 64GB G.Skill Trident Z RGB
      • Storage:
      • 2TB Seagate Firecuda 520
      • Graphics card(s):
      • EVGA GeForce RTX 3080 XC3 Ultra
      • PSU:
      • EVGA SuperNOVA 850W G3
      • Case:
      • NZXT H210i
      • Operating System:
      • Ubuntu 20.04, Windows 10
      • Monitor(s):
      • LG 34GN850
      • Internet:
      • FIOS
    the certificate authority who issued the target server's certificate is unknown

    this is considered a security breach, and isn't allowed (as it could be a hacker's own CA, and offers you no implicit or explicit trust)

    i don't know the java way of doing things, but you need to import the CA's public certificate (on ubuntu, that appears to be under system/preferences/sun java 6 control panel/security/certificates). good luck getting a certificate into the right format though!

  3. #3
    Chillie in here j.o.s.h.1408's Avatar
    Join Date
    Dec 2005
    Location
    a place called home
    Posts
    8,545
    Thanks
    757
    Thanked
    256 times in 193 posts
    • j.o.s.h.1408's system
      • Motherboard:
      • ASUS P6T Delux
      • CPU:
      • Intel core i7 920 @ 3ghz
      • Memory:
      • 3GB DDR RAM
      • Storage:
      • 1TB Samsung F1, 500GB Seagate baracuda + 320gb Seagate PATA +150GB WD PATA
      • Graphics card(s):
      • EVGA 480GTX SC edition
      • PSU:
      • Seasonic M12 600W Module PSU FTW
      • Case:
      • Lian Li PC-A7010B (the rolls royce of pc cases)
      • Operating System:
      • vista ultimate edition and windows xp
      • Monitor(s):
      • 22inch 2005FPW dell monitor
      • Internet:
      • 24mb BE There Broadband
    umm im gunna try and get the certificate from the php server somehow and then import it into my project.

    how come on a regular web browser it works by allowing you to install the certificate? how come in phone devices you cant?
    Last edited by j.o.s.h.1408; 01-05-2007 at 02:40 PM.

  4. #4
    Comfortably Numb directhex's Avatar
    Join Date
    Jul 2003
    Location
    /dev/urandom
    Posts
    17,074
    Thanks
    228
    Thanked
    1,027 times in 678 posts
    • directhex's system
      • Motherboard:
      • Asus ROG Strix B550-I Gaming
      • CPU:
      • Ryzen 5900x
      • Memory:
      • 64GB G.Skill Trident Z RGB
      • Storage:
      • 2TB Seagate Firecuda 520
      • Graphics card(s):
      • EVGA GeForce RTX 3080 XC3 Ultra
      • PSU:
      • EVGA SuperNOVA 850W G3
      • Case:
      • NZXT H210i
      • Operating System:
      • Ubuntu 20.04, Windows 10
      • Monitor(s):
      • LG 34GN850
      • Internet:
      • FIOS
    in a secure scenario, you don't necessarily want to allow the user to randomly install certificates easily

    consider an app which connects to a secure company server for some reason - users will always click "yeah whatever" to bad ssl certificate warnings, so it's safer to place the onus on the admins/developers to ensure certificates are properly trusted

  5. #5
    Chillie in here j.o.s.h.1408's Avatar
    Join Date
    Dec 2005
    Location
    a place called home
    Posts
    8,545
    Thanks
    757
    Thanked
    256 times in 193 posts
    • j.o.s.h.1408's system
      • Motherboard:
      • ASUS P6T Delux
      • CPU:
      • Intel core i7 920 @ 3ghz
      • Memory:
      • 3GB DDR RAM
      • Storage:
      • 1TB Samsung F1, 500GB Seagate baracuda + 320gb Seagate PATA +150GB WD PATA
      • Graphics card(s):
      • EVGA 480GTX SC edition
      • PSU:
      • Seasonic M12 600W Module PSU FTW
      • Case:
      • Lian Li PC-A7010B (the rolls royce of pc cases)
      • Operating System:
      • vista ultimate edition and windows xp
      • Monitor(s):
      • 22inch 2005FPW dell monitor
      • Internet:
      • 24mb BE There Broadband
    ok cheers. i will try and get the certificate from our server guy but its proving to be a pain has his not giving it to me!

    anyways i tried using a normal http connection and i managed to connect to the server but when i try to right something back to the server i get ajava.lang.illegalStateException stating a "Write attemped after request finished"

    im using J2ME with netbeans by the way

    here is a revised version of my code. hope someone can help thanks..


    Code:
    public void open()
        {
            try
            {
                server = (HttpConnection) Connector.open(url2);
                
                server.setRequestMethod(HttpConnection.POST);
                server.setRequestProperty("If-Modified-Since",
                "29 Oct 1999 19:43:31 GMT");
                server.setRequestProperty("User-Agent",
                "Profile/MIDP-2.0 Configuration/CLDC-1.0");
                server.setRequestProperty("Content-Language", "en-US");
                
                is = server.openInputStream();
                os = server.openOutputStream();
                
                
               
                
                details();
                /*
                Alert alert = new Alert ("Error");
                alert.setString("ok" + " " + data[0]);
                alert.setTimeout (3000);
                Display.getDisplay(root).setCurrent(alert);
                //something = getResponse();
                int gfdgf;
                 **/
            }
            catch(Exception e)
            {
                e.printStackTrace();
                String error = e.toString();
                Alert alert = new Alert ("Error");
                alert.setString("Error, " + e);
                alert.setTimeout (5000);
                Display.getDisplay(root).setCurrent(alert);
                    
                    
            }
        }
    details method that retreives data and stores into a array

    Code:
    public void details()
        {
            try
            {
                String username = details[0] + "\n" + "\0";
                String pass = details[1] + "\n" + "\0";
                
                os.write(username.getBytes());
                os.flush();
                os.write(pass.getBytes());
                os.flush();
                
                for(int i = 0; i < 20; i++)
                {
                    data[i] = getResponse();
                }
            }
            catch(Exception e)
            {
                e.printStackTrace();
                String error = e.toString();
                Alert alert = new Alert ("Error");
                alert.setString("Error2, " + e);
                alert.setTimeout (5000);
                Display.getDisplay(root).setCurrent(alert);
            }
            
            
            
            
            
        }
    and finaly the method that reads a line of data from the web server

    Code:
    public String getResponse()
        {
            StringBuffer b = new StringBuffer();
            String read = "";
            int ch = 0;
            try
            {
               
    
                
                
                    while(( (ch = is.read()) != '\n') )
                    {
                        b.append((char) ch);
                    }
    
                    read = b.toString();
                    b.setLength(0);
                 
                
            }
            catch(IOException e)
            {
               e.printStackTrace();
               read = "error";
            }
            return read;
            
                            
        }

  6. #6
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    Shouldn't

    Code:
    while(( (ch = is.read()) != '\n') )
    be

    Code:
    while(( (ch = is.read()) != '\r\n') )
    To support other platforms? Windows is \n, *nix is \r and mac's are \r\n I think.

  7. #7
    Chillie in here j.o.s.h.1408's Avatar
    Join Date
    Dec 2005
    Location
    a place called home
    Posts
    8,545
    Thanks
    757
    Thanked
    256 times in 193 posts
    • j.o.s.h.1408's system
      • Motherboard:
      • ASUS P6T Delux
      • CPU:
      • Intel core i7 920 @ 3ghz
      • Memory:
      • 3GB DDR RAM
      • Storage:
      • 1TB Samsung F1, 500GB Seagate baracuda + 320gb Seagate PATA +150GB WD PATA
      • Graphics card(s):
      • EVGA 480GTX SC edition
      • PSU:
      • Seasonic M12 600W Module PSU FTW
      • Case:
      • Lian Li PC-A7010B (the rolls royce of pc cases)
      • Operating System:
      • vista ultimate edition and windows xp
      • Monitor(s):
      • 22inch 2005FPW dell monitor
      • Internet:
      • 24mb BE There Broadband
    i changed that part of the code and it diddnt make a difference has the error seems to point towards my os.write statement

  8. #8
    Comfortably Numb directhex's Avatar
    Join Date
    Jul 2003
    Location
    /dev/urandom
    Posts
    17,074
    Thanks
    228
    Thanked
    1,027 times in 678 posts
    • directhex's system
      • Motherboard:
      • Asus ROG Strix B550-I Gaming
      • CPU:
      • Ryzen 5900x
      • Memory:
      • 64GB G.Skill Trident Z RGB
      • Storage:
      • 2TB Seagate Firecuda 520
      • Graphics card(s):
      • EVGA GeForce RTX 3080 XC3 Ultra
      • PSU:
      • EVGA SuperNOVA 850W G3
      • Case:
      • NZXT H210i
      • Operating System:
      • Ubuntu 20.04, Windows 10
      • Monitor(s):
      • LG 34GN850
      • Internet:
      • FIOS
    Quote Originally Posted by Kezzer View Post
    Shouldn't

    Code:
    while(( (ch = is.read()) != '\n') )
    be

    Code:
    while(( (ch = is.read()) != '\r\n') )
    To support other platforms? Windows is \n, *nix is \r and mac's are \r\n I think.
    *nix is \n, windows is \r\n, macos 9 is \r

  9. #9
    Chillie in here j.o.s.h.1408's Avatar
    Join Date
    Dec 2005
    Location
    a place called home
    Posts
    8,545
    Thanks
    757
    Thanked
    256 times in 193 posts
    • j.o.s.h.1408's system
      • Motherboard:
      • ASUS P6T Delux
      • CPU:
      • Intel core i7 920 @ 3ghz
      • Memory:
      • 3GB DDR RAM
      • Storage:
      • 1TB Samsung F1, 500GB Seagate baracuda + 320gb Seagate PATA +150GB WD PATA
      • Graphics card(s):
      • EVGA 480GTX SC edition
      • PSU:
      • Seasonic M12 600W Module PSU FTW
      • Case:
      • Lian Li PC-A7010B (the rolls royce of pc cases)
      • Operating System:
      • vista ultimate edition and windows xp
      • Monitor(s):
      • 22inch 2005FPW dell monitor
      • Internet:
      • 24mb BE There Broadband
    well i have been testing this code using http instead of a ssl connection.

    The problem im having on the actual phone device is that it only works when i use the built in wifi connection on my nokia n95. When i try to use my 3g/gprs connection, it doesnt work!

    im on T mobile with web and walk so i shouldnt have any problems at all. I tried accessing the http link directly from the phones web browser and that worked.

    Please note that the application im building is suppose to connect to multiple http and socket connections simultaneus. the socket connection works but not the http via from the phones gprs/3g access point

    anyways here is a revised code for my http connection. Thanks.


    Code:
    server = (HttpConnection) Connector.open(url);
                
                server.setRequestMethod(HttpConnection.POST);
              
                
                
                int rc = server.getResponseCode();
                if (rc == HttpConnection.HTTP_OK) 
                {
                   is = server.openInputStream();
                    
                }
                else
                {
                    root.notifyDestroyed();
                     Alert alert = new Alert ("Error");
                    alert.setString("Error, server is down");
                    alert.setTimeout (5000);
                    Display.getDisplay(root).setCurrent(alert);
                    throw new IOException("HTTP response code: " + rc);
                }

  10. #10
    Seething Cauldron of Hatred TheAnimus's Avatar
    Join Date
    Aug 2005
    Posts
    17,168
    Thanks
    803
    Thanked
    2,152 times in 1,408 posts
    I don't know for sure with T-mobile.

    But i'd assume this is a proxy problem.

    Java is really, well sun would say Platform Agnostic. I'd say proprietry crap that runs equally crap on almost every device.... But i digress.

    The problem here I'm guessing is the proxy not been set up by default on the Java connection.
    throw new ArgumentException (String, String, Exception)

  11. #11
    Chillie in here j.o.s.h.1408's Avatar
    Join Date
    Dec 2005
    Location
    a place called home
    Posts
    8,545
    Thanks
    757
    Thanked
    256 times in 193 posts
    • j.o.s.h.1408's system
      • Motherboard:
      • ASUS P6T Delux
      • CPU:
      • Intel core i7 920 @ 3ghz
      • Memory:
      • 3GB DDR RAM
      • Storage:
      • 1TB Samsung F1, 500GB Seagate baracuda + 320gb Seagate PATA +150GB WD PATA
      • Graphics card(s):
      • EVGA 480GTX SC edition
      • PSU:
      • Seasonic M12 600W Module PSU FTW
      • Case:
      • Lian Li PC-A7010B (the rolls royce of pc cases)
      • Operating System:
      • vista ultimate edition and windows xp
      • Monitor(s):
      • 22inch 2005FPW dell monitor
      • Internet:
      • 24mb BE There Broadband
    Yea it seems like its the gprs connection problem. But how can i fix this? my gprs is automaticly set by t mobile web and walk.

    All the http links work from within the phones we browser but not on a MIDLET program which is strange

  12. #12
    Seething Cauldron of Hatred TheAnimus's Avatar
    Join Date
    Aug 2005
    Posts
    17,168
    Thanks
    803
    Thanked
    2,152 times in 1,408 posts
    I don't know with T-Mobile, but i'd assume its a proxy problem (as said above).

    Enjoy finding this on java!
    throw new ArgumentException (String, String, Exception)

  13. #13
    Chillie in here j.o.s.h.1408's Avatar
    Join Date
    Dec 2005
    Location
    a place called home
    Posts
    8,545
    Thanks
    757
    Thanked
    256 times in 193 posts
    • j.o.s.h.1408's system
      • Motherboard:
      • ASUS P6T Delux
      • CPU:
      • Intel core i7 920 @ 3ghz
      • Memory:
      • 3GB DDR RAM
      • Storage:
      • 1TB Samsung F1, 500GB Seagate baracuda + 320gb Seagate PATA +150GB WD PATA
      • Graphics card(s):
      • EVGA 480GTX SC edition
      • PSU:
      • Seasonic M12 600W Module PSU FTW
      • Case:
      • Lian Li PC-A7010B (the rolls royce of pc cases)
      • Operating System:
      • vista ultimate edition and windows xp
      • Monitor(s):
      • 22inch 2005FPW dell monitor
      • Internet:
      • 24mb BE There Broadband
    i found IT!!!!!!!!!!!! damm t-mobiles web and walk have a restriction againts http connections and on certain websites. it appears that you have to prove to them that your over 18 by giving them your credit card details and letting them check if its legit. if it is then you are able to browse any site and make http connections from programs!

    i found this out by looking closely at the response code i get from the url, i notice that its a redirected url response which basicly means hey, you cant go to this url so we will transfer you to a different url that tells you that you need to prove that your over 18

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. graphics card error
    By amit12345 in forum PC Hardware and Components
    Replies: 0
    Last Post: 09-04-2007, 03:43 PM
  2. Sharing a mac's internet connection with windows PCs
    By Mike Fishcake in forum Networking and Broadband
    Replies: 5
    Last Post: 17-11-2006, 07:22 PM
  3. Argh! Internet connection not working
    By subucni in forum Help! Quick Relief From Tech Headaches
    Replies: 7
    Last Post: 30-11-2005, 08:13 AM
  4. Did my OC cause this?
    By myth in forum PC Hardware and Components
    Replies: 19
    Last Post: 05-04-2005, 12:36 PM
  5. 8o!! taste hot WineX powaaah!
    By directhex in forum Software
    Replies: 33
    Last Post: 31-05-2004, 08:18 PM

Posting Permissions

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