summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/base/x509_cert_types.cc11
-rw-r--r--net/base/x509_cert_types.h4
2 files changed, 15 insertions, 0 deletions
diff --git a/net/base/x509_cert_types.cc b/net/base/x509_cert_types.cc
index 8f7a2ae..9c1369d 100644
--- a/net/base/x509_cert_types.cc
+++ b/net/base/x509_cert_types.cc
@@ -49,6 +49,17 @@ bool CertPrincipal::Matches(const CertPrincipal& against) const {
match(domain_components, against.domain_components);
}
+std::string CertPrincipal::GetDisplayName() const {
+ if (!common_name.empty())
+ return common_name;
+ if (!organization_names.empty())
+ return organization_names[0];
+ if (!organization_unit_names.empty())
+ return organization_unit_names[0];
+
+ return std::string();
+}
+
std::ostream& operator<<(std::ostream& s, const CertPrincipal& p) {
s << "CertPrincipal[";
if (!p.common_name.empty())
diff --git a/net/base/x509_cert_types.h b/net/base/x509_cert_types.h
index 8693ba9..1a788a7d 100644
--- a/net/base/x509_cert_types.h
+++ b/net/base/x509_cert_types.h
@@ -69,6 +69,10 @@ struct CertPrincipal {
// where "match" is defined in RFC 5280 sec. 7.1.
bool Matches(const CertPrincipal& against) const;
+ // Returns a name that can be used to represent the issuer. It tries in this
+ // order: CN, O and OU and returns the first non-empty one found.
+ std::string GetDisplayName() const;
+
// The different attributes for a principal. They may be "".
// Note that some of them can have several values.