x509_cert_types.h 1.8 KB

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