61 X509_NAME_oneline(X509_get_subject_name(cert),
nullptr, 0),
63 { OPENSSL_free(p); });
65 return std::string(subject.get());
66 return std::string(
"");
72 if (subject_bio ==
nullptr)
74 return std::string(
"");
77 X509_NAME_print_ex(subject_bio.get(),
78 X509_get_subject_name(cert),
82 | ASN1_STRFLGS_UTF8_CONVERT
83 | ASN1_STRFLGS_ESC_CTRL);
84 if (BIO_eof(subject_bio.get()))
86 return std::string(
"");
89 BUF_MEM *subject_mem =
nullptr;
90 BIO_get_mem_ptr(subject_bio.get(), &subject_mem);
91 return std::string(subject_mem->data,
92 subject_mem->data + subject_mem->length);
98 BIO *bio = BIO_new(BIO_s_mem());
100 PEM_write_bio_X509(bio, cert);
101 size_t len = BIO_get_mem_data(bio, &data);
102 std::string certpem{data, len};
138 static const char nullc =
'\0';
140 X509_NAME *x509_name = X509_get_subject_name(cert);
141 int i = X509_NAME_get_index_by_NID(x509_name, nid, -1);
144 X509_NAME_ENTRY *ent = X509_NAME_get_entry(x509_name, i);
147 ASN1_STRING *val = X509_NAME_ENTRY_get_data(ent);
149 buf = (
unsigned char *)1;
151 const int len = ASN1_STRING_to_UTF8(&buf, val);
154 if (std::strlen((
char *)buf) ==
static_cast<unsigned int>(len))
162 i = X509_get_ext_by_NID(cert, nid, -1);
165 X509_EXTENSION *
ext = X509_get_ext(cert, i);
168 BIO *bio = BIO_new(BIO_s_mem());
171 if (X509V3_EXT_print(bio,
ext, 0, 0))
173 if (BIO_write(bio, &nullc, 1) == 1)
176 const long len = BIO_get_mem_data(bio, &
str);
177 if (std::strlen(
str) ==
static_cast<size_t>(len))