+Certificate::Certificate (string cert)
+{
+ read_string (cert);
+}
+
+Certificate::Certificate (Certificate const & other)
+{
+ read_string (other.certificate (true));
+}
+
+void
+Certificate::read_string (string cert)
+{
+ BIO* bio = BIO_new_mem_buf (const_cast<char *> (cert.c_str ()), -1);
+ if (!bio) {
+ throw MiscError ("could not create memory BIO");
+ }
+
+ _certificate = PEM_read_bio_X509 (bio, 0, 0, 0);
+ if (!_certificate) {
+ throw MiscError ("could not read X509 certificate from memory BIO");
+ }
+
+ BIO_free (bio);
+}
+