Lev Walkin wrote:

>> I have found that asn1.h has a declaration of a function:
>> i2a_ASN1_INTEGER()
>>
>> which outputs a hexadecimal representation of the serial number value to the 
>> BIO
variable.
>> I wish not to use a bio structure variable, but a simple char variable, that 
>> I could
use
>> in other parts of my application code.
>
>
>Write the function wrapping the BIO stuff:
>
>BIO *bp = BIO_new(BIO_s_mem());
>BUF_MEM *bptr;
>char *return_value;
>if(i2a_ASN1_INTEGER(...))) {
>BIO_get_mem_ptr(bp, &bptr);
>return_value = strndup(bptr->data, bptr->length);
>                    } else {
>return_value = NULL;
>}
>BIO_free(bp);
>return return_value;
>
>--
>Lev Walkin
>[EMAIL PROTECTED]



Thanks for your answer. I already solved the problem another way without 
involving BIO,
but using ASN1 and BIGNUM convertion funtions. Below is the simple code I used:

char * serialHex;
 BIGNUM *serialBN = NULL;
...
serialBN = ASN1_INTEGER_to_BN(X509_get_serialNumber(cert),NULL);
serialHex = BN_bn2hex(serialBN);

The above gives me a hexadecimal representation of the serial number stored in 
a char
variable.
That is what I initially wanted to achieve.

Thanks for your help.

Przemek

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [email protected]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to