Getting the peer certificate chain - Openssl

This is a discussion on Getting the peer certificate chain - Openssl ; Hi all,
How to get the peer certificate chain during SSL connection establishment ?
Any example program is greatly appreciated.
Thanks in advance,
Cheers,
Aravind....