Enforcing a specific certificate

I am trying to establish a secure connection with a remote machine and I wish to ensure that I am connected to the machine I expect by validating its certificate. All of this with the purpose of using JavaMail to send an email via smtp on this secure connection.

My problem here is that I can't figure out how to validate a specific certificate. I have tried using a custom KeyStore so that only one certificate would be accepted instead of resolving the trusted Certificate Authorities. But by doing so, I had to implement a custom SSLSocketFactory which doesn't seem to be possible with Java 1.4.2 because of the non backward compatible changes that occured on java.net.Socket.

Any suggestions, code samples or URLs to tutorials would be very appreciated.

Thanks

PS: I have already consulted the following documents while trying to solve this problem:

http://java.sys-con.com/read/216388.htm

http://www.javaworld.com/javatips/jw-javatip115.html

Message was edited by:

Dalzhim

[1035 byte] By [Dalzhima] at [2007-11-22]
# 1
One of my coworkers found a solution to the problem. The problem was due to the fact I referred to the certificate using the javax.net.ssl.keyStore property instead of the javax.net.ssl.trustStore property.Now everything is working fine.
Dalzhima at 2007-7-15 > top of java,Security,Java Secure Socket Extension (JSSE)...