logo       

FW: stunnel and java ---: msg#00045

network.stunnel.user

Subject: FW: stunnel and java ---


Hi
I am new to stunnel.....I need some help .....i want to write some
adapter for mycustomer....They opened stunnel for my ipaddress but we did not
open an stunnel from ourside (Thats why i am currently using https to connect
to their site .Once S-tunnel enabled from ourside then i should connect only
with http ) .So i am currently using this url in browser.

https://123.456.789.123:12038/lic.cgi?msisdn=+491771234567&serviceid=13&type=getcobyno
..i am getting results

but i am unable to get the results if i am using java program .....


i am using jdk1.4.1 on windows 2000 ...i hope when we use stunnel there is no
necessary to send certificates to server for handshake?Then how should i
proceed.

I am not sure whether i should miss something here....like basic steps to
enable stunnel.



please find the source code and exception ...



import java.net.*;
import java.io.*;
import java.security.*;
import java.security.cert.*;
import javax.net.ssl.*;
public class DialogsRead
{

public static void main(String[] argv) throws Exception
{
try
{

URL url = new URL("http://123.456.789.123:12038/lic.cgi?";);
HttpURLConnection connection = (HttpURLConnection)
url.openConnection();

connection.setDoOutput(true);
connection.setDoInput(true);
connection.setUseCaches(false);
connection.setRequestMethod("GET");
connection.setRequestProperty("connection","keep-alive");
PrintWriter out = new PrintWriter(connection.getOutputStream());

String name = "msisdn="+URLEncoder.encode("01771234567", "UTF-8");
String id = "&serviceid="+URLEncoder.encode("13", "UTF-8");
String type="&type="+URLEncoder.encode("getcobyno","UTF-8");
String res=name+id+type;

out.println(res);
//out.close();
out.flush();

BufferedReader in = new BufferedReader(new
InputStreamReader(connection.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
System.out.println(line);
}
//in.close();
}
catch (MalformedURLException me)
{
System.out.println("MALFORMED URL: " + me.getMessage());
me.printStackTrace();
}
catch (IOException ie)
{
System.out.println("IO EXCEPTION: " + ie.getMessage());
ie.printStackTrace();
}

}



}



If i use https ://123.456.789.123:12038/lic.cgi? ; i am getting following
error



IO EXCEPTION: java.security.cert.CertificateException: Could not find trusted
certificate
javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException:
Could not find trusted certificate
at com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.a(DashoA6275)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA6275)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA6275)
at com.sun.net.ssl.internal.ssl.SunJSSE_az.a(DashoA6275)
at com.sun.net.ssl.internal.ssl.SunJSSE_az.a(DashoA6275)
at com.sun.net.ssl.internal.ssl.SunJSSE_ax.a(DashoA6275)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA6275)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.j(DashoA6275)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(DashoA6275)
at sun.net.www.protocol.https.HttpsClient.afterConnect(DashoA6275)
at
sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(DashoA6275)
at
sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:528)
at
sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(DashoA6275)
at DialogsRead.main(DialogsRead.java:22)
Caused by: java.security.cert.CertificateException: Could not find trusted
certificate
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.a(DashoA6275)
at
com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(DashoA6275)
at
com.sun.net.ssl.internal.ssl.JsseX509TrustManager.checkServerTrusted(DashoA6275)
... 11 more
Process terminated with exit code 0



If i use http ://123.456.789.123:12038/lic.cgi? ; i am getting following
error


IO EXCEPTION: Connection reset
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:168)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:222)
at java.io.BufferedInputStream.read(BufferedInputStream.java:277)
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:741)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:702)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:712)
at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:583)
at DialogsRead.main(DialogsRead.java:33)
Process terminated with exit code 0





Thanks in Advance

shanta.B



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise