61 X509_NAME_oneline(X509_get_subject_name(cert),
nullptr, 0),
63 { OPENSSL_free(p); });
65 return std::string(subject.get());
67 return std::string(
"");
73 if (subject_bio ==
nullptr)
75 return std::string(
"");
78 X509_NAME_print_ex(subject_bio.get(),
79 X509_get_subject_name(cert),
83 | ASN1_STRFLGS_UTF8_CONVERT
84 | ASN1_STRFLGS_ESC_CTRL);
85 if (BIO_eof(subject_bio.get()))
87 return std::string(
"");
90 BUF_MEM *subject_mem =
nullptr;
91 BIO_get_mem_ptr(subject_bio.get(), &subject_mem);
92 return std::string(subject_mem->data,
93 subject_mem->data + subject_mem->length);
99 BIO *bio = BIO_new(BIO_s_mem());
101 PEM_write_bio_X509(bio, cert);
102 size_t len = BIO_get_mem_data(bio, &data);
103 std::string certpem{data, len};
140 static const char nullc =
'\0';
142 X509_NAME *x509_name = X509_get_subject_name(cert);
143 int i = X509_NAME_get_index_by_NID(x509_name, nid, -1);
146 X509_NAME_ENTRY *ent = X509_NAME_get_entry(x509_name, i);
149 ASN1_STRING *val = X509_NAME_ENTRY_get_data(ent);
151 buf = (
unsigned char *)1;
153 const int len = ASN1_STRING_to_UTF8(&buf, val);
156 if (std::strlen((
char *)buf) ==
static_cast<unsigned int>(len))
164 i = X509_get_ext_by_NID(cert, nid, -1);
167 X509_EXTENSION *
ext = X509_get_ext(cert, i);
170 BIO *bio = BIO_new(BIO_s_mem());
173 if (X509V3_EXT_print(bio,
ext, 0, 0))
175 if (BIO_write(bio, &nullc, 1) == 1)
178 const long len = BIO_get_mem_data(bio, &
str);
179 if (std::strlen(
str) ==
static_cast<size_t>(len))