Certificate.h
Go to the documentation of this file.
1 /****
2  * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development.
3  * Created 2015 by Skurydin Alexey
4  * http://github.com/SmingHub/Sming
5  * All files of the Sming Core are provided under the LGPL v3 license.
6  *
7  * Certificate.h
8  *
9  * @author: 2019 - Slavey Karadzhov <slav@attachix.com>
10  *
11  ****/
12 
13 #pragma once
14 
15 #include <WString.h>
16 #include "Fingerprints.h"
17 
18 namespace Ssl
19 {
25 #define SSL_X509_RDN_OID_MAP(XX) \
26  XX(COMMON_NAME, 2, 5, 4, 3) \
27  XX(SURNAME, 2, 5, 4, 4) \
28  XX(SERIAL_NUMBER, 2, 5, 4, 5) \
29  XX(COUNTRY_NAME, 2, 5, 4, 6) \
30  XX(LOCALITY_NAME, 2, 5, 4, 7) \
31  XX(STATE_OR_PROVINCE_NAME, 2, 5, 4, 8) \
32  XX(STREET_ADDRESS, 2, 5, 4, 9) \
33  XX(ORGANIZATION_NAME, 2, 5, 4, 10) \
34  XX(ORGANIZATIONAL_UNIT_NAME, 2, 5, 4, 11) \
35  XX(TITLE, 2, 5, 4, 12) \
36  XX(BUSINESS_CATEGORY, 2, 5, 4, 15) \
37  XX(POSTAL_ADDRESS, 2, 5, 4, 16) \
38  XX(POSTAL_CODE, 2, 5, 4, 17) \
39  XX(GIVEN_NAME, 2, 5, 4, 42) \
40  XX(GENERATION_QUALIFIER, 2, 5, 4, 44) \
41  XX(X500_UNIQUE_IDENTIFIER, 2, 5, 4, 45) \
42  XX(DN_QUALIFIER, 2, 5, 4, 46) \
43  XX(PSEUDONYM, 2, 5, 4, 65)
44 
49 {
50 public:
54  enum class DN {
55  ISSUER,
56  SUBJECT,
57  };
58 
62  enum class RDN {
63 #define XX(tag, a, b, c, d) tag,
65 #undef XX
66  MAX
67  };
68 
69  virtual ~Certificate()
70  {
71  }
72 
79  virtual bool getFingerprint(Fingerprint::Type type, Fingerprint& fingerprint) const = 0;
80 
87  virtual String getName(DN dn, RDN rdn) const = 0;
88 
92  size_t printTo(Print& p) const;
93 };
94 
99 
100 } // namespace Ssl
#define SSL_X509_RDN_OID_MAP(XX)
X509 Relative Distinguished Name type.
Definition: Certificate.h:25
Provides formatted output to stream.
Definition: Print.h:37
Implemented by SSL adapter to handle certificate operations.
Definition: Certificate.h:49
virtual ~Certificate()
Definition: Certificate.h:69
DN
Distinguished Name type.
Definition: Certificate.h:54
virtual bool getFingerprint(Fingerprint::Type type, Fingerprint &fingerprint) const =0
Obtain certificate fingerprint.
RDN
Relative Distinguished Name type identifying a name component.
Definition: Certificate.h:62
XX(tag, a, b, c, d)
virtual String getName(DN dn, RDN rdn) const =0
Retrieve an X.509 distinguished name component.
size_t printTo(Print &p) const
Debugging print support.
The String class.
Definition: WString.h:137
Definition: Alert.h:16
String toString(Certificate::RDN rdn)
Obtain a string describing the given name component.
Various types of fingerprint.
Definition: Fingerprints.h:27
Type
SSL Certificate fingerprint type.
Definition: Fingerprints.h:31