Java and X509 Certificates .. help!!  
Author Message
paxtra





PostPosted: 2006-8-17 14:42:00 Top

java-programmer, Java and X509 Certificates .. help!! Hello,

I need some help! I would like to know if it is possible to get, from
the browser (web client), the server X509 certificate used by it in an
already SSL established session with the client (browser). As in the
server side, with your application you can get the client X509
certificate used by the client in order to authenticate himself, it
should be an analogous process or API in the web client to get the
server certificate.

The aim is to develop some client script (preferable JavaScript, but
could be with Java Applet) in order to deal with the server X509
certificate fields.

Can you help me? Thanks in advance!!

Best regards,

 
pax





PostPosted: 2006-9-4 18:23:00 Top

java-programmer >> Java and X509 Certificates .. help!! Hello,

I need some help! I would like to know if it is possible to get, from
the browser (web client), the server X509 certificate used by it in an
already SSL established session with the client (browser). As in the
server side, with your application you can get the client X509
certificate used by the client in order to authenticate himself, it
should be an analogous process or API in the web client to get the
server certificate.

The aim is to develop some client script (preferable JavaScript, but
could be with Java Applet) in order to deal with the server X509
certificate fields.

Can you help me? Thanks in advance!!

Best regards,

 
ram_no_spam_marti





PostPosted: 2006-9-6 3:08:00 Top

java-programmer >> Java and X509 Certificates .. help!!
Could n't you get the SSLSession from the SSLSocket using getSession and
then use getPeerCertificate or getPeerCertificatChain to get the
certificates?

something like this..
.....

SSLSession session = socket.getSession();
java.security.cert.Certificate certs[] =
session.getPeerCertificates();
for (int i=0; i < certs.length; i++) {
System.out.println("Certificate[" + i + "]" + certs[i]);
}
javax.security.cert.X509Certificate X509certs[] =
session.getPeerCertificateChain();
for (int i=0; i < certs.length; i++) {
System.out.println("X509 Certificate[" + i + "]" + X509certs[i]);
}


.....

= Ram Marti

pax wrote:
> Hello,
>
> I need some help! I would like to know if it is possible to get, from
> the browser (web client), the server X509 certificate used by it in an
> already SSL established session with the client (browser). As in the
> server side, with your application you can get the client X509
> certificate used by the client in order to authenticate himself, it
> should be an analogous process or API in the web client to get the
> server certificate.
>
> The aim is to develop some client script (preferable JavaScript, but
> could be with Java Applet) in order to deal with the server X509
> certificate fields.
>
> Can you help me? Thanks in advance!!
>
> Best regards,
>