• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Snigdha Solanki
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You get redirected from https://www.google.com to non-secure http://www.google.com.

Is this what you expected?
 
Frank Cohen
author
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic