Here is a function to do what you want that i just wrote today. At least i hope its what you want. Good luck!.
void ShowCerts(SSL* ssl)
{ X509 *cert;
{ X509 *cert;
char buf[100];
/* get the server's certificate */
cert = SSL_get_peer_certificate(ssl);
if ( cert != NULL )
{
/* issuer */
X509_NAME_get_text_by_NID(cert->cert_info->subject, NID_commonName, buf,sizeof(buf));
printf(" Subject-CN: %s\n", buf);
X509_NAME_get_text_by_NID(cert->cert_info->issuer, NID_commonName, buf,sizeof(buf));
printf(" Issuer-CN: %s\n", buf);
X509_NAME_get_text_by_NID(cert->cert_info->issuer, NID_countryName, buf,sizeof(buf));
printf(" Issuer Country: %s\n", buf);
X509_NAME_get_text_by_NID(cert->cert_info->issuer, NID_organizationName, buf,sizeof(buf));
printf(" Issuer Organisation: %s\n", buf);
}
else
printf("No certificates.\n");
}
Bernhard Froehlich <[EMAIL PROTECTED]> wrote:
cert = SSL_get_peer_certificate(ssl);
if ( cert != NULL )
{
/* issuer */
X509_NAME_get_text_by_NID(cert->cert_info->subject, NID_commonName, buf,sizeof(buf));
printf(" Subject-CN: %s\n", buf);
X509_NAME_get_text_by_NID(cert->cert_info->issuer, NID_commonName, buf,sizeof(buf));
printf(" Issuer-CN: %s\n", buf);
X509_NAME_get_text_by_NID(cert->cert_info->issuer, NID_countryName, buf,sizeof(buf));
printf(" Issuer Country: %s\n", buf);
X509_NAME_get_text_by_NID(cert->cert_info->issuer, NID_organizationName, buf,sizeof(buf));
printf(" Issuer Organisation: %s\n", buf);
}
else
printf("No certificates.\n");
}
Bernhard Froehlich <[EMAIL PROTECTED]> wrote:
vipin rathor wrote:
> hi all,
> I want to develop a small utility in C to show all information
> about the X509 certificate file in a structured comprehensive(as
> displayed by browsers like IE). i'm working on SLES 9. so please help
> me out....
> one more thing, i know the routines like X509_get_subject_name()
> and X509_get_issuer_name(), but i can not find the manaul pages for
> these routines. where can i get that??? moreover i want other
> information about other routines as well that can give me all
> information about the certificate.
> An early response will be appreciated.
You should have a look at
http://www.openssl.org/docs/crypto/X509_NAME_print_ex.html, I think it
is quite close to what you want.
Otherwise I'd suggest to have a look at the sources of the X509-utility
of OpenSSL
Hope it helps.
Ted
;)
--
PGP Public Key Information
Download complete Key from http://www.convey.de/ted/tedkey_convey.asc
Key fingerprint = 31B0 E029 BCF9 6605 DAC1 B2E1 0CC8 70F4 7AFB 8D26
Yahoo! Mail
Use Photomail to share photos without annoying attachments.