Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Exception java.io.IOException: Server Certificate SubjectDN  RSS feed

 
vasu devan
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
Objective : One servlet(SimpleServlet.java) need to contact another servlet(FinalServlet.java) through https
For your information, we are trying to contact the other servlet through URL connection, and this is not a browser based thing.
We are using the JSSE and we are using the following jar files
jcert.jar
jsse.jar
jnet.jar
httpsclient.jar
And we wrote a small java program(Sample.java) which will contact the final servlet(FinalServlet.java). And it is working fine.
And we wrote a simple servlet(SimpleServlet.java) where we created object for Sample.java and tried to contact the servlet (FinalServlet.java) through https
And we got the following error message.
Exception java.io.IOException: Server Certificate SubjectDN CommonName received does not match Server hostname
Please give us some tips to overcome this problem.
Thanks in Advance,
Vasu.
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your server certificate is invalid because the hostname is absent or wrong. The solution is to either generate/get a better certificate or (if you're not bothered about this particular mode of attack) to use your own javax.net.ssl.HostnameVerifier. For example,to disable hostname verification globally, orto disable it for this specific connection. More documentation here.
Does this help?
- Peter
 
Junaid Bhatra
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of disabling hostname verification altogether, you can also do a smart comparison using the InetAddress class. My earlier post here talks about this.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!