|
| 1 | +#pragma once |
| 2 | + |
| 3 | +#include"Client.h" |
| 4 | + |
| 5 | + |
| 6 | +namespacearduino { |
| 7 | + |
| 8 | +// Tls CertificatesKeys are strings |
| 9 | +using CertificateKey =constchar[]; |
| 10 | + |
| 11 | +enumclassCertificateFormat { |
| 12 | + Der, |
| 13 | + Pem, |
| 14 | +} |
| 15 | + |
| 16 | +classTls:publicClientConnect { |
| 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 | +virtualvoidsetIdentityVerification(IdentityVerification mode) { _mode = mode; }; |
| 27 | +virtualvoidsetCA(CertificateKey ca, CertificateFormat f=CertificateFormat::Pem) = 0; |
| 28 | +virtualvoidsetCertificate(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 | +virtualvoidsniVerification(bool) = 0; |
| 35 | + |
| 36 | +// manually provide an hostname that will be used toghether with sni |
| 37 | +// if connect is called with hostname as parameter this will be automatically called |
| 38 | +virtualvoidsetHostname(constchar hostname[]) = 0; |
| 39 | +protected: |
| 40 | + IdentityVerification _mode; |
| 41 | +}; |
| 42 | + |
| 43 | +classTlsClient:publicClient, Tls { |
| 44 | + |
| 45 | +}; |
| 46 | +} |