If the extension “.crt” refers to a PEM text file (starts with ----- BEGIN CERTIFICATE ----- followed by base64), then start working with OpenSSL documents here .
Here is some code to get started (link with ssl, for example g ++ ac -lssl):
#include <stdio.h> #include <openssl/x509.h> #include <openssl/pem.h> int main(int argc, char** argv) { FILE* f = fopen("certifi.crt", "r"); if (f != NULL) { X509* x509 = PEM_read_X509(f, NULL, NULL, NULL); if (x509 != NULL) { char* p = X509_NAME_oneline(X509_get_issuer_name(x509), 0, 0); if (p) { printf("NAME: %s\n", p); OPENSSL_free(p); } X509_free(x509); } } return 0; }
source share