Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

java.io.IOException: HTTPS hostname wrong:

 
Hassam Khan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,

I am new in using https. I tried to get an outputStream like this:

===========================================================
URL interURL;

interURL = new URL(etpMsg.getHostURL().trim());

HttpURLConnection urlcon = (HttpURLConnection)interURL.openConnection();
urlcon.setRequestMethod("POST");
urlcon.setDoOutput(true);
urlcon.setDoInput(true);
urlcon.setUseCaches(false);

System.out.println("<----------------- After Open Connection ---->");

BufferedWriter outputData = new BufferedWriter(new OutputStreamWriter(urlcon.getOutputStream()));
=============================================================

The above code gives me the following exception:

java.io.IOException: HTTPS hostname wrong


My URL looks like this:

"https://12.12.12.124:4442/"


On other hand, when i tried to hit that URL from browser, it gives me a Security Alert with the following description

"The name on the security certificate is invalid or does not match the name of the site".

Please help where i am doing wrong.

Thanks,

Regards,
Hassam
[ December 21, 2006: Message edited by: Hassam Khan ]
 
Joe Ess
Bartender
Posts: 9362
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like it is working correctly to me. SSL certificates are issued according to host name. The host you are contacting does not have an SSL certificate that matches it's host name. Since the HttpURLConnection does not have a way to inform the user that the SSL conversation may be insecure, it fails.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!