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

IOException: Server Certificate SubjectDN  RSS feed

 
Nathan KV
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Objective : One servlet(SimpleServlet.java) need to contact a servlet(FinalServlet.java) in https mode
For your information, we need to write program to contact the other servlet, 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.
 
Junaid Bhatra
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a commonly encountered problem in SSL/HTTPS. What is happening is that the servername of the server, as obtained from the digital certificate, does not match the URL you are trying to connect to. For eg, maybe the servername listed in the digital certificate is www.yourdomain.com and you are trying to connect to the server using it's IP address? The easiest way to overcome this problem is to make sure that when you create the URL, the servername should match the one listed in the certificate. However this may not always be a feasible soultion, so there is another solution to this:
Have a look at the HostNameVerifier interface in the com.sun.net.ssl package. The following sample code might give you an idea:

[ May 07, 2002: Message edited by: Junaid Bhatra ]
 
Nathan KV
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank's Junaid Bhatra for your suggestion.
I have modified the java program Simple.java and used the 'InetAddress' as suggested by Junaid Bhatra. And i executed the java program Simple.java directly and it is working fine.
But when a sevlet(SimpleServlet.java) calls the function which is in the same java program(Simple.java), it is not working. It is giving the same error. Why ?
on the whole, When i execute the java program (Simple.java) from the servlet, it is not working. What could be the reason.
Please give us some idea.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!