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
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