ESP32 HTTPS Server
httpsserver::SSLCert Class Reference

Certificate and private key that can be passed to the HTTPSServer. More...

#include <SSLCert.hpp>

Public Member Functions

 SSLCert (unsigned char *certData=NULL, uint16_t certLength=0, unsigned char *pkData=NULL, uint16_t pkLength=0)
 Creates a new SSLCert. More...
 
uint16_t getCertLength ()
 Returns the length of the certificate in byte.
 
uint16_t getPKLength ()
 Returns the length of the private key in byte.
 
unsigned char * getCertData ()
 Returns the certificate data.
 
unsigned char * getPKData ()
 Returns the private key data.
 
void setPK (unsigned char *_pkData, uint16_t length)
 Sets the private key in DER format. More...
 
void setCert (unsigned char *_certData, uint16_t length)
 Sets the certificate data in DER format. More...
 
void clear ()
 Clears the key buffers and deletes them.
 

Detailed Description

Certificate and private key that can be passed to the HTTPSServer.

Converting PEM to DER Files

Certificate:

openssl x509 -inform PEM -outform DER -in myCert.crt -out cert.der

Private Key:

openssl rsa -inform PEM -outform DER -in myCert.key -out key.der

Converting DER File to C Header

echo "#ifndef KEY_H_" > ./key.h
echo "#define KEY_H_" >> ./key.h
xxd -i key.der >> ./key.h
echo "#endif" >> ./key.h

Constructor & Destructor Documentation

◆ SSLCert()

httpsserver::SSLCert::SSLCert ( unsigned char *  certData = NULL,
uint16_t  certLength = 0,
unsigned char *  pkData = NULL,
uint16_t  pkLength = 0 
)

Creates a new SSLCert.

The certificate and key data may be NULL (default values) if the certificate is meant to be passed to createSelfSignedCert().

Otherwise, the data must reside in a memory location that is not deleted until the server using the certificate is stopped.

Parameters
[in]certDataThe certificate data to use (DER format)
[in]certLengthThe length of the certificate data
[in]pkDataThe private key data to use (DER format)
[in]pkLengthThe length of the private key

Member Function Documentation

◆ setCert()

void httpsserver::SSLCert::setCert ( unsigned char *  _certData,
uint16_t  length 
)

Sets the certificate data in DER format.

The data has to reside in a place in memory that is not deleted as long as the server is running.

See SSLCert for some information on how to generate DER data.

Parameters
[in]_certDataThe data of the certificate
[in]lengthThe length of the certificate

◆ setPK()

void httpsserver::SSLCert::setPK ( unsigned char *  _pkData,
uint16_t  length 
)

Sets the private key in DER format.

The data has to reside in a place in memory that is not deleted as long as the server is running.

See SSLCert() for some information on how to generate DER data.

Parameters
[in]_pkDataThe data of the private key
[in]lengthThe length of the private key

The documentation for this class was generated from the following files: