X509_free (_certificate);
}
+string
+Certificate::certificate () const
+{
+ BIO* bio = BIO_new (BIO_s_mem ());
+ if (!bio) {
+ throw MiscError ("could not create memory BIO");
+ }
+
+ PEM_write_bio_X509 (bio, _certificate);
+
+ string s;
+ char* data;
+ long int const data_length = BIO_get_mem_data (bio, &data);
+ for (long int i = 0; i < data_length; ++i) {
+ s += data[i];
+ }
+
+ BIO_free (bio);
+
+ boost::replace_all (s, "-----BEGIN CERTIFICATE-----\n", "");
+ boost::replace_all (s, "-----END CERTIFICATE-----\n", "");
+ return s;
+}
+
string
Certificate::issuer () const
{
Certificate (X509 *);
~Certificate ();
+ std::string certificate () const;
std::string issuer () const;
std::string serial () const;
std::string subject () const;
list<shared_ptr<Certificate> > c = certificates.leaf_to_root ();
for (list<shared_ptr<Certificate> >::iterator i = c.begin(); i != c.end(); ++i) {
xmlpp::Element* data = key_info->add_child("X509Data", "dsig");
+
{
xmlpp::Element* serial = data->add_child("X509IssuerSerial", "dsig");
serial->add_child("X509IssuerName", "dsig")->add_child_text(
);
serial->add_child("X509SerialNumber", "dsig")->add_child_text((*i)->serial());
}
+
+ data->add_child("X509Certificate", "dsig")->add_child_text((*i)->certificate());
}
+ doc.write_to_file_formatted ("/home/carl/fuckwit.xml", "UTF-8");
+
xmlSecKeysMngrPtr keys_manager = xmlSecKeysMngrCreate();
if (!keys_manager) {
throw MiscError ("could not create keys manager");