From f0d2a59b20021d3582727978050641eaa8ccee30 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 29 Sep 2013 09:10:44 +0100 Subject: Add common_name(). --- src/certificates.cc | 8 ++++++++ src/certificates.h | 1 + 2 files changed, 9 insertions(+) (limited to 'src') diff --git a/src/certificates.cc b/src/certificates.cc index 4c41ebba..f23dbc5d 100644 --- a/src/certificates.cc +++ b/src/certificates.cc @@ -193,6 +193,14 @@ Certificate::subject () const return name_for_xml (X509_get_subject_name (_certificate)); } +string +Certificate::common_name () const +{ + assert (_certificate); + + return get_name_part (X509_get_subject_name (_certificate), NID_commonName); +} + string Certificate::serial () const { diff --git a/src/certificates.h b/src/certificates.h index 198773f1..2bf8d0db 100644 --- a/src/certificates.h +++ b/src/certificates.h @@ -58,6 +58,7 @@ public: std::string issuer () const; std::string serial () const; std::string subject () const; + std::string common_name () const; /** @return RSA public key from this Certificate. Caller must not free the returned value. */ RSA* public_key () const; -- cgit v1.2.3