Dmitri Bogutski wrote:
Nils Larsch wrote:
Dmitri Bogutski wrote:
Hello,
How to get a DER-encoded of the certificate issuer name?
I do the following:
BIO *mem;
X509 *x;
X509_NAME *issuer;
/* 'buf' is a buffer the containing certificate read from an ID-card */
/* 'len' - length of certificate */
mem = BIO_new_mem_buf(buf, len);
/* decode from DER format into X509 structure */
x = d2i_X509_bio(mem, NULL);
/* return the X509_NAME encoding for the issuer of this certificate */
issuer = X509_get_issuer_name(x);
Whether 'issuer->bytes->data' contains the DER-encoded string?
It should, but to be sure call i2d_X509_NAME(issuer, NULL) before
using issuer->bytes->data.
Thank you for answer.
How be in that case?
....
ASN1_INTEGER *serial;
....
serial = X509_get_serialNumber(x);
What function should be called for using 'serial->data' as DER-encoded
string?
Use the normal i2d_ASN1_INTEGER() function, i.e. (without
error checking):
int len;
unsigned char *buf, *p;
len = i2d_ASN1_INTEGER(serial, 0);
buf = OPENSSL_malloc(len);
p = buf;
i2d_ASN1_INTEGER(serial, &p);
after that buf points to the DER encoded ASN1 integer
(see FAQ: "How do I read or write a DER encoded ...").
Regards,
Nils
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]