Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7642271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:08:48+00:00 2026-05-31T09:08:48+00:00

I am using openssl to get data about x509 certificate. Is there a way

  • 0

I am using openssl to get data about x509 certificate.
Is there a way to convert ASN1_INTEGER to ASN1_STRING, which can than easily be transformed to char array? Is there a way to convert it to any other human readable format?

EDIT: I’m using openssl compiled for iOS, as I am having the iOS project. Here is the code I am using to extract the serial number from the certificate:

ASN1_INTEGER *serial = X509_get_serialNumber(certificateX509);
long value = ASN1_INTEGER_get(serial);
NSLog(@"Serial %ld", value);

certificateX509 is a valid X509 object and I have managed to get some other fields from it (issuer name, expiry date and so on)

EDIT 2:
I finally came to a solution, which may not be the most straightforward one:

 ASN1_INTEGER *serial = X509_get_serialNumber(certificateX509);
 BIGNUM *bnser = ASN1_INTEGER_to_BN(serial, NULL);
 int n = BN_num_bytes(bnser);
 unsigned char outbuf[n];
 int bin = BN_bn2bin(bnser, outbuf);
 char *hexbuf = (char*) outbuf;

hexBuf then contains characters whose value needs to be read as hex integer in order to retrieve logical values.
I use NSMutableString to create a human readable string:

NSMutableString *str = [[NSMutableString alloc] init];
for (int i=0; i<n; i++) {
    NSString *temp = [NSString stringWithFormat:@"%.6x", hexbuf[i]];
    [str appendString:[NSString stringWithFormat:@"%@ ", temp]];
}

If there is a simpler way, I would really like to know it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T09:08:50+00:00Added an answer on May 31, 2026 at 9:08 am

    I finally came to a solution, which may not be the most straightforward one:

     ASN1_INTEGER *serial = X509_get_serialNumber(certificateX509);
     BIGNUM *bnser = ASN1_INTEGER_to_BN(serial, NULL);
     int n = BN_num_bytes(bnser);
     unsigned char outbuf[n];
     int bin = BN_bn2bin(bnser, outbuf);
     char *hexBuf = (char*) outbuf;
    

    hexBuf then contains characters whose value needs to be read as hex integer in order to retrieve logical values.
    I use NSMutableString to create a human readable string:

     NSMutableString *str = [[NSMutableString alloc] init];
        for (int i=0; i<n; i++) {
        NSString *temp = [NSString stringWithFormat:@"%.6x", hexbuf[i]];
        [str appendString:[NSString stringWithFormat:@"%@ ", temp]];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have generated using openssl mycert.pem which contents the certificate. And I converted the
I am trying to implement a DTLS server using OpenSSL. I can get app
I'm using openssl BIO objects to convert a binary string into a base64 string.
I'm using the openssl utility of debian in order to create a certificate. The
Why does the hash from using openssl differ from the ones I get in
I want to use DTLS (on OpenSSL) using JNI on Android 2.1/2.2. Can someone
Whenever I try to base64 decode files (using OpenSSL's BIO_f_base64() ) larger than 8192,
I am building an application and I am planning on using OpenSSL for securing
I'm looking to create a hash with sha256 using openssl and C++. I know
I have a legacy C++ module that offers encryption/decryption using the openssl library (DES

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.