1
#pragma once
2

            
3
#include <memory>
4
#include <string>
5
#include <vector>
6

            
7
#include "envoy/common/optref.h"
8

            
9
namespace Envoy {
10
namespace Ssl {
11

            
12
/**
13
 *  Attribute values parsed from a X.509 distinguished name. This only includes some
14
 *  well-known elements such as commonName (CN) and organizationName (O). The purpose is to
15
 *  avoid user parsing the RFC2253 string with their own code. The value will be UTF8 string,
16
 *  which means if the value type can not be converted to UTF8 string we'll just set empty
17
 *  string, to protect from malicious certificate.
18
 */
19
struct ParsedX509Name {
20
  // there should be only one commonName in the distinguished name
21
  std::string commonName_;
22
  // there could be multiple organizationNames
23
  std::vector<std::string> organizationName_;
24
  // TODO: add more well known fields such as L, OU, C, DC, UID etc.
25
};
26

            
27
using ParsedX509NameOptConstRef = OptRef<const ParsedX509Name>;
28
using ParsedX509NamePtr = std::unique_ptr<ParsedX509Name>;
29

            
30
} // namespace Ssl
31
} // namespace Envoy