1 // Copyright 2012 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef NET_CERT_X509_CERT_TYPES_H_ 6 #define NET_CERT_X509_CERT_TYPES_H_ 7 8 #include <string> 9 #include <vector> 10 11 #include "net/base/net_export.h" 12 #include "net/der/input.h" 13 14 namespace net { 15 16 // CertPrincipal represents the issuer or subject field of an X.509 certificate. 17 struct NET_EXPORT CertPrincipal { 18 CertPrincipal(); 19 explicit CertPrincipal(const std::string& name); 20 ~CertPrincipal(); 21 22 // Configures handling of PrintableString values in the DistinguishedName. Do 23 // not use non-default handling without consulting //net owners. With 24 // kAsUTF8Hack, PrintableStrings are interpreted as UTF-8 strings. 25 enum class PrintableStringHandling { kDefault, kAsUTF8Hack }; 26 27 // Parses a BER-format DistinguishedName. 28 bool ParseDistinguishedName( 29 der::Input ber_name_data, 30 PrintableStringHandling printable_string_handling = 31 PrintableStringHandling::kDefault); 32 33 // Returns a name that can be used to represent the issuer. It tries in this 34 // order: CN, O and OU and returns the first non-empty one found. 35 std::string GetDisplayName() const; 36 37 // The different attributes for a principal, stored in UTF-8. They may be "". 38 // Note that some of them can have several values. 39 40 std::string common_name; 41 std::string locality_name; 42 std::string state_or_province_name; 43 std::string country_name; 44 45 std::vector<std::string> street_addresses; 46 std::vector<std::string> organization_names; 47 std::vector<std::string> organization_unit_names; 48 std::vector<std::string> domain_components; 49 }; 50 51 } // namespace net 52 53 #endif // NET_CERT_X509_CERT_TYPES_H_ 54