Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 47eb863

Browse files
Introducing Tls apis in Arduino Core api
Added Interfaces to handle Tls api standardization in arduino core api.
1 parent eee27b0 commit 47eb863

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

api/Tls.h

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

0 commit comments

Comments
 (0)