ESP32 HTTPS Server: /home/frank/Projekte/esp32/https_server/esp32_https_server/src/SSLCert.hpp Source File
6 #ifndef HTTPS_DISABLE_SELFSIGNING
9 #include <mbedtls/entropy.h>
10 #include <mbedtls/ctr_drbg.h>
13 #include <mbedtls/x509_crt.h>
14 #include <mbedtls/x509_csr.h>
16 #define HTTPS_SERVER_ERROR_KEYGEN 0x0F
17 #define HTTPS_SERVER_ERROR_KEYGEN_RNG 0x02
18 #define HTTPS_SERVER_ERROR_KEYGEN_SETUP_PK 0x03
19 #define HTTPS_SERVER_ERROR_KEYGEN_GEN_PK 0x04
20 #define HTTPS_SERVER_ERROR_KEY_WRITE_PK 0x05
21 #define HTTPS_SERVER_ERROR_KEY_OUT_OF_MEM 0x06
22 #define HTTPS_SERVER_ERROR_CERTGEN 0x1F
23 #define HTTPS_SERVER_ERROR_CERTGEN_RNG 0x12
24 #define HTTPS_SERVER_ERROR_CERTGEN_READKEY 0x13
25 #define HTTPS_SERVER_ERROR_CERTGEN_WRITE 0x15
26 #define HTTPS_SERVER_ERROR_CERTGEN_OUT_OF_MEM 0x16
27 #define HTTPS_SERVER_ERROR_CERTGEN_NAME 0x17
28 #define HTTPS_SERVER_ERROR_CERTGEN_SERIAL 0x18
29 #define HTTPS_SERVER_ERROR_CERTGEN_VALIDITY 0x19
31 #endif // !HTTPS_DISABLE_SELFSIGNING
76 unsigned char * certData = NULL,
78 unsigned char * pkData = NULL,
114 void setPK(unsigned char * _pkData, uint16_t length);
127 void setCert(unsigned char * _certData, uint16_t length);
136 unsigned char * _certData;
142 #ifndef HTTPS_DISABLE_SELFSIGNING
176 int createSelfSignedCert(SSLCert &certCtx, SSLKeySize keySize, std::string dn, std::string validFrom = "20190101000000", std::string validUntil = "20300101000000");
178 #endif // !HTTPS_DISABLE_SELFSIGNING
uint16_t getPKLength()
Returns the length of the private key in byte.
Definition: SSLCert.cpp:22
void clear()
Clears the key buffers and deletes them.
Definition: SSLCert.cpp:44
RSA key with 2048 bit.
Definition: SSLCert.hpp:153
RSA key with 1024 bit.
Definition: SSLCert.hpp:151
unsigned char * getCertData()
Returns the certificate data.
Definition: SSLCert.cpp:26
Certificate and private key that can be passed to the HTTPSServer.
Definition: SSLCert.hpp:59
int createSelfSignedCert(SSLCert &certCtx, SSLKeySize keySize, std::string dn, std::string validFrom, std::string validUntil)
Creates a self-signed certificate on the ESP32.
Definition: SSLCert.cpp:287
SSLCert(unsigned char *certData=NULL, uint16_t certLength=0, unsigned char *pkData=NULL, uint16_t pkLength=0)
Creates a new SSLCert.
Definition: SSLCert.cpp:5
void setCert(unsigned char *_certData, uint16_t length)
Sets the certificate data in DER format.
Definition: SSLCert.cpp:39
unsigned char * getPKData()
Returns the private key data.
Definition: SSLCert.cpp:30
RSA key with 4096 bit.
Definition: SSLCert.hpp:155
uint16_t getCertLength()
Returns the length of the certificate in byte.
Definition: SSLCert.cpp:18
Definition: ConnectionContext.cpp:3
void setPK(unsigned char *_pkData, uint16_t length)
Sets the private key in DER format.
Definition: SSLCert.cpp:34
SSLKeySize
Defines the key size for key generation.
Definition: SSLCert.hpp:149