Getting an https connection on a PDA using the CrEme V4.0 jvm

N

Niels Campbell

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.HttpClient.<init>()
at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.<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.www.protocol.https.HttpsURLConnection.getOutputStream()


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.engineGenerateCertificate()
at java.security.cert.CertificateFactory.generateCertificate()
at sun.security.provider.JavaKeyStore.engineLoad()
at java.security.KeyStore.load()
at com.sun.net.ssl.internal.ssl.TrustManagerFactoryImpl.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
 

LP1

Joined
Apr 4, 2008
Messages
1
Reaction score
0
GPRS problem

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top