summaryrefslogtreecommitdiff
path: root/src/certificates.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-01-03 21:01:26 +0000
committerCarl Hetherington <cth@carlh.net>2013-01-03 21:01:26 +0000
commit6a0c75ae216a36438537c1ebcb817e0250c7168e (patch)
tree3c138125a55a25058f64da20602be9f0032652af /src/certificates.cc
parent50b5f8f9df0439d2d8fa9004e0b4af2f3e1eb44c (diff)
Fix missing certificates in CPLs.
Diffstat (limited to 'src/certificates.cc')
-rw-r--r--src/certificates.cc24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/certificates.cc b/src/certificates.cc
index fe03f10e..621f44f2 100644
--- a/src/certificates.cc
+++ b/src/certificates.cc
@@ -27,6 +27,30 @@ Certificate::~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
{
X509_NAME* n = X509_get_issuer_name (_certificate);