new certificate attribute get methods
This commit is contained in:
		| @@ -286,9 +286,68 @@ namespace openssl { | ||||
|              c); | ||||
|         return std::string((char*)c, SHA_DIGEST_LENGTH); | ||||
|       } | ||||
|       //! Get label. | ||||
|       std::string label() const { | ||||
|         return std::string(); | ||||
|       //! Get common name. | ||||
|       std::string commonName() 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_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: | ||||
|       ::X509* _x509; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user