new certificate attribute get methods

master
Marc Wäckerlin 15 years ago
parent d3793f30a2
commit 8f38360ef7
  1. 65
      src/openssl.hxx

@ -286,9 +286,68 @@ namespace openssl {
c); c);
return std::string((char*)c, SHA_DIGEST_LENGTH); return std::string((char*)c, SHA_DIGEST_LENGTH);
} }
//! Get label. //! Get common name.
std::string label() const { std::string commonName() const {
return std::string(); X509_NAME *name(X509_get_subject_name(_x509));
ASN1_STRING* cn
(X509_NAME_ENTRY_get_data
(X509_NAME_get_entry
(name, X509_NAME_get_index_by_NID(name, NID_commonName, -1))));
return std::string((char*)M_ASN1_STRING_data(cn),
M_ASN1_STRING_length(cn));
}
//! Get country name.
std::string countryName() const {
X509_NAME *name(X509_get_subject_name(_x509));
ASN1_STRING* cn
(X509_NAME_ENTRY_get_data
(X509_NAME_get_entry
(name, X509_NAME_get_index_by_NID(name, NID_countryName, -1))));
return std::string((char*)M_ASN1_STRING_data(cn),
M_ASN1_STRING_length(cn));
}
//! Get locality name.
std::string localityName() const {
X509_NAME *name(X509_get_subject_name(_x509));
ASN1_STRING* cn
(X509_NAME_ENTRY_get_data
(X509_NAME_get_entry
(name, X509_NAME_get_index_by_NID(name, NID_localityName, -1))));
return std::string((char*)M_ASN1_STRING_data(cn),
M_ASN1_STRING_length(cn));
}
//! Get state or province name.
std::string stateOrProvinceName() const {
X509_NAME *name(X509_get_subject_name(_x509));
ASN1_STRING* cn
(X509_NAME_ENTRY_get_data
(X509_NAME_get_entry
(name, X509_NAME_get_index_by_NID
(name, NID_stateOrProvinceName, -1))));
return std::string((char*)M_ASN1_STRING_data(cn),
M_ASN1_STRING_length(cn));
}
//! Get organization name.
std::string organizationName() const {
X509_NAME *name(X509_get_subject_name(_x509));
ASN1_STRING* cn
(X509_NAME_ENTRY_get_data
(X509_NAME_get_entry
(name, X509_NAME_get_index_by_NID
(name, NID_organizationName, -1))));
return std::string((char*)M_ASN1_STRING_data(cn),
M_ASN1_STRING_length(cn));
}
//! Get organizational unit name.
std::string organizationalUnitName() const {
X509_NAME *name(X509_get_subject_name(_x509));
ASN1_STRING* cn
(X509_NAME_ENTRY_get_data
(X509_NAME_get_entry
(name, X509_NAME_get_index_by_NID
(name, NID_organizationalUnitName, -1))));
return std::string((char*)M_ASN1_STRING_data(cn),
M_ASN1_STRING_length(cn));
} }
private: private:
::X509* _x509; ::X509* _x509;

Loading…
Cancel
Save