Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

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

 
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
author
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic