Compare commits

..

No commits in common. "9022a21f2c197cbed711f62cb3475a06ce662c88" and "7cda2704e7b0ecfb833a4bc1887406d9ba25c94e" have entirely different histories.

6 changed files with 66 additions and 126 deletions

View File

@ -524,29 +524,24 @@ static int connect( int argc, char *argv[] )
fflush( stdout ); fflush( stdout );
FILE* f; FILE* f;
f = fopen( opt.serial, "r" ); f = fopen( opt.serial, "w+" );
if(f){
mbedtls_mpi_read_file(&serial,10,f); //Nacitavanie serioveho cisla do premennej typu mpi zo suboru
}else if( ( ret = mbedtls_mpi_read_file(&serial,10,f) ) != 0 )
{ {//ak subor neexistuje tak sa nacita seriove cislo zo stringu "1"
fclose(f); mbedtls_mpi_read_string( &serial, 10, "1");
fopen(opt.serial,"w"); // mbedtls_strerror( ret, buf, 1024 );
mbedtls_mpi_read_string( &serial, 10, "0"); // mbedtls_printf( " failed\n ! mbedtls_mpi_read_string "
// "returned -0x%04x - %s\n\n", -ret, buf );
//goto exit;
} }
fclose(f);
/*Zvysenie serioveho cisla o +1*/ /*Zvysenie serioveho cisla o +1*/
mbedtls_mpi_add_int(&serial,&serial,1); mbedtls_mpi_add_int(&serial,&serial,1);
/*Zapis serioveho cisla do suboru*/ /*Zapis serioveho cisla do suboru*/
f = fopen( opt.serial, "w" );
mbedtls_mpi_write_file(NULL,&serial,10,f); mbedtls_mpi_write_file(NULL,&serial,10,f);
fclose( f ); fclose( f );
mbedtls_printf( " ok\n" ); mbedtls_printf( " ok\n" );
// Parse issuer certificate if present // Parse issuer certificate if present

View File

@ -1,15 +0,0 @@
-----BEGIN CERTIFICATE-----
MIICKDCCAYigAwIBAgIBAjAMBggqhkjOPQQDAgUAMC8xETAPBgNVBAMMCEVTUDMy
X0NBMQ0wCwYDVQQKDARUVUtFMQswCQYDVQQGEwJTSzAeFw0wMTAxMDEwMDAwMDBa
Fw0zMDEyMzEyMzU5NTlaMC8xETAPBgNVBAMMCEVTUDMyX0NBMQ0wCwYDVQQKDARU
VUtFMQswCQYDVQQGEwJTSzCB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WO3
AD2BS1xluszT1wE9FZahLqlQIpy7viII8W6RyLcjHsj/EOK73+jcyKzhyqOX0E/g emBurfOcDq4EGEaxRKAU0814VEmU87btIDx80+z5Dbf+GGHCPrY7odIkxGNn0DJY
lhHB6GOGv9B9BELrlVP4MlG47kDiXZpa3hhCUL4IuQhUejOLttLtpbvf3qzV6OLv W1WcF+DOcbiWoUN6DTkAML0SMnp8aGj9ffx3x+qoggT+vGdWVVA4pgwqZT7Ybntx
UhGSkpstIAqUxb85GZdjGJpLxMIFxDV6ZIj1mm+R+z2UcYTO5sBtEgsEMgraj/x8 bkzcNFW0sqmCv4IN1t4w6L0A87ZwsNwVpre/j6uyBw7s8YoJHDLRFT6g7qgn0tcN
bShp3AuclQvva7TvvZKIxa53v5SGs41Bmbz/B7XI2I5fzoFC7k/3zLEsReeQ9qg3 ZufhNISvgWCVJQy/SZjNBHSpnIdCUSJAeTY2mkM4sGxY0Widk8LnjydxZUSxC3Nl
0V6UUMlSv+6xcAYwUF2joEMFE8RYSs6tVRh3yHoGlngu08tbf3vLZ/XHj2tkXTnD hb6pnMh3jRq4h0+5CZielA4/a+TdrNPv/qok67ot/XJdY3qHCCd8O2b14OVq9jo=
Na9raei70fQGtUU3atIkhkY=
-----END CERTIFICATE----- -----END CERTIFICATE-----

View File

@ -1,27 +1,28 @@
-----BEGIN RSA PRIVATE KEY----- -----BEGIN PRIVATE KEY-----
MIIEpAIBAAKCAQEAn4LXgTvdUVOCPODVhF0F2rB6vDWHk+YgxhR31fZFnOcxNw+9 MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCwYp7epz++0QkH
DIpda+3LSukp/QBn7xrd+cZBTTK9tfDIVDF4e2nnedk0HkHyuKcnyOKUzyFdtE04 JioMD7U7BitLgpcYPi8Cid1l7snt6Kp546iQsDBJ3l8xnRtPU7ANEsjT8KxIHmyw
B8fwFCebM3SF68lynHDN2liUfUD9GkddgPMpHI2BPSBnAivCpj19JwLCWE9heg25 h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MygHJVlW9A8CgYEAmK8p/FQ8JrG93J2Uz1wISAabNM76BVIghryd 4PxcknEEh8DR5hsM/IbDcrCJQglM19ZtQeW3LKkY4BsIxjDf45ymH407IQKBgE/g
6MJgLjsKYTnE94ao4NHJZdB71exeRRpD382Ts0BOf1xc/nyzk8QB3y0FpHETuvsH Ul6cPfOxQRlNLH4VMVgInSyyxWx1mODFy7DRrgCuh5kTVh+QUVBM8x9lcwAn8V9/
ejwi31wpOl5AXed7DZOgctax5pEjp1vLrSPFnHx4+XN9CEfiLQJR7idG1SpTvBv1 nQT55wR8E603pznqY/jX0xvAqZE6YVPcw4kpZcwNwL1RhEl8GliikBlRzUL3SsW3
kqib8CUCgYBTu9CNS5WfQC/YbKYeU1F6lYRNw79mVmQfAJyL/aUrSGJuUcZo+kZv q30AfqEViHPE3XpE66PPo6Hb1ymJCVr77iUuC3wtAoGBAIBrOGunv1qZMfqmwAY2
Rq6QfB7mJDLwniwgVALAGhiDJPagstyajUCSkrV9lDleAPOfb4ep0HQK1GA2Jrs6 lxlzRgxgSiaev0lTNxDzZkmU/u3dgdTwJ5DDANqPwJc6b8SGYTp9rQ0mbgVHnhIB
ldn8NTn7z9pToWbgMyl25vaoSMzIjVJ7uic3LN+iruXpxDpBAFqrfA== jcJQBQkTfq6Z0H6OoTVi7dPs3ibQJFrtkoyvYAbyk36quBmNRjVh6rc8468bhXYr
-----END RSA PRIVATE KEY----- v/t+MeGJP/0Zw8v/X2CFll96
-----END PRIVATE KEY-----

View File

@ -194,51 +194,15 @@ static httpd_handle_t start_webserver(void)
httpd_ssl_config_t conf = HTTPD_SSL_CONFIG_DEFAULT(); httpd_ssl_config_t conf = HTTPD_SSL_CONFIG_DEFAULT();
conf.httpd.stack_size = 12000; conf.httpd.stack_size = 12000;
//pridanie certifikatu do konfiguracie //pridanie certifikatu do konfiguracie
unsigned char *cacert_pem_start = calloc(1200,sizeof(unsigned char));//[1025]; extern const unsigned char cacert_pem_start[] asm("_binary_cacert_pem_start");
//memset(cacert_pem_start,'\0',1025); extern const unsigned char cacert_pem_end[] asm("_binary_cacert_pem_end");
//char line_buffer[66]; conf.cacert_pem = cacert_pem_start;
FILE* fd = fopen("/spiffs/server.crt", "r"); conf.cacert_len = cacert_pem_end - cacert_pem_start;
fseek(fd, 0, SEEK_END);
long int size = ftell(fd);
fseek(fd, 0, SEEK_SET);
int bytes_read = fread(cacert_pem_start, sizeof(unsigned char), size, fd);
/*
if(fd!=NULL){
while(fgets(line_buffer, sizeof(line_buffer)-1, fd)){
strcat(cacert_pem_start,line_buffer);
}
}
*/
fclose(fd);
conf.cacert_pem = (const unsigned char*)cacert_pem_start;
printf("%s", conf.cacert_pem);
conf.cacert_len = size+1;
//pridanie sukromneho kluca do konfiguracie //pridanie sukromneho kluca do konfiguracie
unsigned char *prvtkey_pem_start =calloc(1800,sizeof(unsigned char)); extern const unsigned char prvtkey_pem_start[] asm("_binary_prvtkey_pem_start");
extern const unsigned char prvtkey_pem_end[] asm("_binary_prvtkey_pem_end");
//memset(prvtkey_pem_start,'\0',2050);
// memset(line_buffer,'\0',66);
fd = fopen("/spiffs/server_key.key", "rb");
/*
if(fd!=NULL){
while(fgets(line_buffer, sizeof(line_buffer)-1, fd)){
strcat((char*)prvtkey_pem_start,line_buffer);
}
}
*/
fseek(fd, 0, SEEK_END);
size = ftell(fd);
fseek(fd, 0, SEEK_SET);
bytes_read = fread(prvtkey_pem_start, sizeof(unsigned char), size, fd);
fclose(fd);
conf.prvtkey_pem = prvtkey_pem_start; conf.prvtkey_pem = prvtkey_pem_start;
conf.prvtkey_len = size+1; conf.prvtkey_len = prvtkey_pem_end - prvtkey_pem_start;
//vytvorenie HTTP + SSL servera //vytvorenie HTTP + SSL servera
esp_err_t ret = httpd_ssl_start(&server, &conf); esp_err_t ret = httpd_ssl_start(&server, &conf);
if (ESP_OK != ret) { if (ESP_OK != ret) {

View File

@ -177,13 +177,9 @@ void app_main(void)
//read_file("/spiffs/keyfile.key"); read_file("/spiffs/keyfile.key");
read_file("/spiffs/ca.crt"); read_file("/spiffs/ca.crt");
read_file("/spiffs/server.crt"); read_file("/spiffs/user.crt");
read_file("/spiffs/server_key.key");
read_file("/spiffs/serial.txt");
/* Prompt to be printed before each line. /* Prompt to be printed before each line.
* This can be customized, made dynamic, etc. * This can be customized, made dynamic, etc.
*/ */