![]() |
|
|
|||||||
![]() |
Java - Getting an https connection on a PDA using the CrEme V4.0 jvm |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
Posts: n/a
|
CrEme V4.0
Using the CrEme V4.0 jvm (personal) I was getting a SocketException thrown when trying to make an https connection. I switched on debugging on the command line for starting CrEme 16#"\windows\CrEme\bin\CrEme.exe" -Td0 3 -Of -ntb -vkb -pjava -tiny -classpath \lib\jsse.jar;\lib\jnet.jar;\lib\jcert.jar;\. ProgramName And got the follwoing stack trace java.net.SocketException: SSL implementation not available at javax.net.ssl.DefaultSSLSocketFactory.createSocket () at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.doConnect() at com.sun.net.ssl.internal.www.protocol.https.NetworkClient.openServer() at com.sun.net.ssl.internal.www.protocol.https.HttpClient.l() at com.sun.net.ssl.internal.www.protocol.https.HttpCl ient.<init>() at com.sun.net.ssl.internal.www.protocol.https.HttpsC lient.<init>() at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.a() at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.a() at com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnection.connect() at com.sun.net.ssl.internal.http://www.protocol.https.HttpsURLCo...utputStr eam() I switched on the java net debuging by setting the system property "javax.net.debug" to all. I specified the location of the cacerts file using the system property "javax.net.ssl.trustStore" I specified the protocol handler using the system property "java.protocol.handler.pkgs" The code below ran before I attempted to make a connection. try { Properties properties=System.getProperties(); properties.put("javax.net.ssl.trustStore", "\\Windows\\lib\\security\\cacerts"); properties.put("javax.net.debug", "all"); properties.put("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol"); java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); } catch (Exception e) { e.printStackTrace(); } On decompiling a couple of the classes in PVMclasses.zip I found that the wrong SSL socket factory was being used because the com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl couldn't be created. The reason it wasn't being created was because an IllegalArgumentException was being thrown java.lang.IllegalArgumentException: DER Value conversion at sun.security.x509.AVA.toString() at sun.security.x509.RDN.toString() at sun.security.x509.X500Name.generateDN() at sun.security.x509.X500Name.toString() at sun.security.x509.CertificateIssuerName.toString() at sun.security.x509.X509CertInfo.parse() at sun.security.x509.X509CertInfo.<init>() at sun.security.x509.X509CertImpl.parse() at sun.security.x509.X509CertImpl.<init>() at sun.security.provider.X509Factory.engineGenerateCe rtificate() at java.security.cert.CertificateFactory.generateCert ificate() at sun.security.provider.JavaKeyStore.engineLoad() at java.security.KeyStore.load() at com.sun.net.ssl.internal.ssl.TrustManagerFactoryIm pl.a() at com.sun.net.ssl.internal.ssl.SSLContextImpl$1.run( ) at com.sun.net.ssl.internal.ssl.SSLContextImpl.d() at com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl. <init>() On adding a printStackTrace to the AVA class the reason for the IllegalArgumentException was an UnsupportedEncodingException java.io.UnsupportedEncodingException at sun.io.ByteToCharConverter.getConverter() at java.lang.String.<init>() at java.lang.String.<init>() at sun.security.util.DerValue.getPrintableString() at sun.security.util.DerValue.getAsString() at sun.security.x509.AVA.toString() Decompiling the DerValue class and looking at the getPrintableString() function and comparing it to that of another jvm I noticed a difference. I made the following change to DerValue class public String getPrintableString() throws IOException { if(tag != 19) throw new IOException("DerValue.getPrintableString, not a string " + tag); else return simpleGetString(); // Took this line out // return new String(getDataBytes(), "ASCII"); } // Added the function private String simpleGetString() throws IOException { StringBuffer stringbuffer = new StringBuffer(length); try { int i = length; data.reset(); while(i-- > 0) stringbuffer.append((char)data.getByte()); } catch(IOException ioexception) { return null; } return new String(stringbuffer); } I recompiled this class and added it back into the PVMclasses.zip. On running my application on the pda I was now able to create an https connection. Took me two days to get this. Thanks, Niels |
|
|
|
#2 |
|
Junior Member
Join Date: Apr 2008
Posts: 1
|
Hey Neils
We're running a program called FieldWorker on HP iPAQs and they recently switched from an older Java version to Creme. Now it's not forcing the mobile phone to connect during a synchronize. Since you already know most of the code I was hoping you could tell me how to get it to connect to the GPRS. Currently the only way is to open a browser to a webpage like google which kicks off the connection procedure. Thanks, LP |
|
|
|
![]() |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Losing internet connection after 5 mins? | Alexgtbeetle | General Help Related Topics | 0 | 09-03-2008 02:15 PM |
| Loses Internet Connection | jmoore00 | General Help Related Topics | 0 | 09-24-2007 04:23 AM |
| How to configure VPN | hi5 | Hardware | 1 | 07-09-2007 11:21 AM |
| Sharing wireless Internet connection with wired connected desktop... | josh321 | General Help Related Topics | 0 | 11-14-2006 06:59 PM |
| Laptop wireless connection | johnnygeargrinder2004@yahoo.com | A+ Certification | 7 | 03-09-2005 02:05 AM |