实现代码如下:
#include <openssl/bio.h> X509_NAME *issuer = X509_get_issuer_name(cert); if (issuer != NULL) { BIO *bio = BIO_new(BIO_s_mem()); // 使用 OpenSSL 的“,”分割打印格式 X509_NAME_print_ex(bio, issuer, 0, XN_FLAG_SEP_COMMA_PLUS); char *buf; long len = BIO_get_mem_data(bio, &buf); printf("Issuer: %.*s\n", (int)len, buf); BIO_free(bio); }输出格式示例:
Issuer: OU=GlobalSign Root CA - R3,O=GlobalSign,CN=GlobalSign