How to read client certificate from server side using mbedtls(polarssl)
?
I had a server that was coded using mbedtls(polarssl)
. I want to read the client certificate and fetch some information from that certificate. Can anyone know what function will be used to read client certificate?
Asked
Active
Viewed 656 times
0

talamaki
- 5,324
- 1
- 27
- 40

Ranjithkumar
- 31
- 4
-
Have you taken a look at example programs at https://github.com/ARMmbed/mbedtls/tree/development/programs ? – talamaki Feb 12 '16 at 14:02
1 Answers
0
I think you could use mbedtls_x509_crt_info which returns an informational string about the certificate.
You can get the peer certificate from the ssl session
when the client connects and then print the info out.
mbedtls_ssl_context ssl;
...
mbedtls_x509_crt *crt = ssl.session->peer_cert;
unsigned char buf[1024];
int ret = mbedtls_x509_crt_info((char *) buf, sizeof( buf ) - 1, "", crt);
if( ret != -1 )
{
mbedtls_printf( "%s\n", buf );
}
I didn't test this, just checked the examples.

talamaki
- 5,324
- 1
- 27
- 40