-
Notifications
You must be signed in to change notification settings - Fork 143
Expand file tree
/
Copy pathTls.h
More file actions
46 lines (33 loc) · 1.33 KB
/
Tls.h
File metadata and controls
46 lines (33 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#pragma once
#include "Client.h"
namespace arduino {
// Tls CertificatesKeys are strings
using CertificateKey = const char[];
enum class CertificateFormat {
Der,
Pem,
}
class Tls: public ClientConnect {
public:
virtual ~Tls() = default;
enum IdentityVerification {
MTls, // both ends identity needs to be verified
Tls, // The server side end is verified against CA
Insecure, // no check against server side identity
};
virtual void setIdentityVerification(IdentityVerification mode) { _mode = mode; };
virtual void setCA(CertificateKey ca, CertificateFormat f=CertificateFormat::Pem) = 0;
virtual void setCertificate(CertificateKey public, CertificateKey private, CertificateFormat f=CertificateFormat::Pem) = 0;
// Tls protocol enables Server Name Indication usage, for which a client provides
// the hostname it is trying to connect to. This hostname may be required to be verified
// against the server provided one
virtual void sniVerification(bool) = 0;
// manually provide an hostname that will be used together with sni
// if connect is called with hostname as parameter this will be automatically called
virtual void setHostname(const char hostname[]) = 0;
protected:
IdentityVerification _mode;
};
class TlsClient: public Client, Tls {
};
}