X509 subject to DER

master
Marc Wäckerlin 15 years ago
parent d120572c67
commit 5c60773269
  1. 10
      src/openssl.hxx

@ -205,7 +205,7 @@ namespace openssl {
if (!len) throw x509_copy_failed(); if (!len) throw x509_copy_failed();
const unsigned char* d2(d); const unsigned char* d2(d);
_x509 = d2i_X509(0, &d2, len); _x509 = d2i_X509(0, &d2, len);
free(d); OPENSSL_free(d);
if (!_x509) throw x509_copy_failed(); if (!_x509) throw x509_copy_failed();
} }
//! Take over OpenSSL allocated certificate. //! Take over OpenSSL allocated certificate.
@ -226,6 +226,14 @@ namespace openssl {
_x509 = d2i_X509(0, &d2, len); _x509 = d2i_X509(0, &d2, len);
if (!_x509) throw x509_copy_failed(); if (!_x509) throw x509_copy_failed();
} }
//! Get DER encoded subject.
std::string subjectDER() const {
char* c(0);
int len(i2d_X509_NAME(X509_get_subject_name(_x509), &c));
std::String res(c, len);
OPENSSL_free(c);
return res;
}
private: private:
::X509* _x509; ::X509* _x509;
}; };

Loading…
Cancel
Save