aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes javax.net.ssl.SSLException: error while writing to socket Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "javax.net.ssl.SSLException: error while writing to socket" Watch "javax.net.ssl.SSLException: error while writing to socket" New topic
Author

javax.net.ssl.SSLException: error while writing to socket

Snigdha Solanki
Ranch Hand

Joined: Sep 07, 2000
Posts: 128
Hi,

I am writing a java program that reads the content from a secured site.
It is successfully able to open a URL connection but is not able to read the content type and the length and gives the following exception -

Computed URL is https://www.google.com
Content-type = null
Content-length = -1
javax.net.ssl.SSLException: error while writing to socket
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.b(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.AppOutputStream.write(DashoA6275)
at java.io.OutputStream.write(OutputStream.java:58)
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.followRedirect(HttpURLConnection.java:1082)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:663)
at sun.net.www.protocol.http.HttpURLConnection.getHeaderField(HttpURLConnection.java:1122)
at java.net.URLConnection.getContentType(URLConnection.java:381)
at com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnectionOldImpl.getContentType(DashoA6275)
at UseHttps.main(UseHttps.java:80)

Code snippet -



Any idea as to what is going wrong?

thanks,
Snigdha
Catalin Merfu
Ranch Hand

Joined: May 26, 2004
Posts: 42
You get redirected from https://www.google.com to non-secure http://www.google.com.

Is this what you expected?


Catalin Merfu<br /><a href="http://www.accendia.com" target="_blank" rel="nofollow">High Performance Java Networking</a>
Frank Cohen
author
Greenhorn

Joined: Apr 17, 2004
Posts: 18
One thing to keep in mind is Google's use policy. They specifically do not allow Java HTTPSUrlConnection objects to connect to the Google site. It may be that their server is returning a purposefully bad result.

-Frank Cohen
Author of Java Testing and Design at http://thebook.pushtotest.com


---<br />Frank Cohen, <a href="http://www.PushToTest.com" target="_blank" rel="nofollow">http://www.PushToTest.com</a> phone: 408 374 7426<br />Enterprise test automation solutions to check and monitor Web-enabled <br />applications for functionality, scalability and reliability.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: javax.net.ssl.SSLException: error while writing to socket