Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Security / March 2004

Tip: Looking for answers? Try searching our database.

Retrieving SSL server certificate without performing client authentication

Thread view: 
Thilo-Alexander Ginkel - 17 Mar 2004 15:06 GMT
Hello,

I am currently looking for a method to obtain the X.509 certificate of a
SSL server which has client authentication enabled. Unfortunately, I do
not have access to the correct client certificate at the time I need to
retrieve the server certificate. My current Java implementation works well
when client authentication is disabled:

-- 8< --
[...]
SSLContext       ctx  = UserSSLContextFactory.getDefault().getContext("TLS");
SSLSocketFactory sf   = ctx.getSocketFactory();
SSLSocket        sock = (SSLSocket) sf.createSocket(host, port);

sock.setUseClientMode(true);
sock.setEnableSessionCreation(true);

SSLSession       sess = sock.getSession();

javax.security.cert.X509Certificate[] chain = null;

try {
    sock.startHandshake();
    chain = sess.getPeerCertificateChain();
} catch (IOException e) { };
[...]
-- 8< --

Unfortunately, as soon as client authentication is enabled on the server,
sock.startHandshake() throws an exception and there seems to be no way to
get access to the certificate which has already been transferred during
the handshake's ServerHello message.

Is there any way to get access to this information without re-implementing
the whole SSL protocol (or at least the required sub-set)?

Eric Rescorla's PureTLS [1] seems to have the same behavior, but at least
comes with full source code, so I could modify it to fit my needs.

Are there any third-party libraries which have built-in support for this
scenario?

Thanks,
Thilo

[1] http://www.rtfm.com/puretls/
Thilo-Alexander Ginkel - 17 Mar 2004 15:31 GMT
> Unfortunately, as soon as client authentication is enabled on the server,
> sock.startHandshake() throws an exception and there seems to be no way to
> get access to the certificate which has already been transferred during
> the handshake's ServerHello message.

Of course, this should read "Certificate" instead of "ServerHello".

Regards,
Thilo
Thilo-Alexander Ginkel - 18 Mar 2004 13:42 GMT
> Unfortunately, as soon as client authentication is enabled on the server,
> sock.startHandshake() throws an exception and there seems to be no way to
[quoted text clipped - 3 lines]
> Is there any way to get access to this information without re-implementing
> the whole SSL protocol (or at least the required sub-set)?

Problem solved: The TrustManager's checkServerTrusted method is called even
if the handshake fails.

Regards,
Thilo


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.