0.1.0
This commit is contained in:
parent
7cda2704e7
commit
01b0e56804
@ -524,23 +524,28 @@ static int connect( int argc, char *argv[] )
|
||||
fflush( stdout );
|
||||
|
||||
FILE* f;
|
||||
f = fopen( opt.serial, "w+" );
|
||||
f = fopen( opt.serial, "r" );
|
||||
if(f){
|
||||
mbedtls_mpi_read_file(&serial,10,f);
|
||||
}else
|
||||
{
|
||||
fclose(f);
|
||||
fopen(opt.serial,"w");
|
||||
mbedtls_mpi_read_string( &serial, 10, "0");
|
||||
|
||||
//Nacitavanie serioveho cisla do premennej typu mpi zo suboru
|
||||
if( ( ret = mbedtls_mpi_read_file(&serial,10,f) ) != 0 )
|
||||
{//ak subor neexistuje tak sa nacita seriove cislo zo stringu "1"
|
||||
mbedtls_mpi_read_string( &serial, 10, "1");
|
||||
// mbedtls_strerror( ret, buf, 1024 );
|
||||
// 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*/
|
||||
mbedtls_mpi_add_int(&serial,&serial,1);
|
||||
/*Zapis serioveho cisla do suboru*/
|
||||
mbedtls_mpi_write_file(NULL,&serial,10,f);
|
||||
fclose( f );
|
||||
|
||||
f = fopen( opt.serial, "w" );
|
||||
mbedtls_mpi_write_file(NULL,&serial,10,f);
|
||||
|
||||
fclose( f );
|
||||
|
||||
mbedtls_printf( " ok\n" );
|
||||
|
||||
|
@ -1,19 +1,20 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDKzCCAhOgAwIBAgIUBxM3WJf2bP12kAfqhmhhjZWv0ukwDQYJKoZIhvcNAQEL
|
||||
BQAwJTEjMCEGA1UEAwwaRVNQMzIgSFRUUFMgc2VydmVyIGV4YW1wbGUwHhcNMTgx
|
||||
MDE3MTEzMjU3WhcNMjgxMDE0MTEzMjU3WjAlMSMwIQYDVQQDDBpFU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HoGlngu08tbf3vLZ/XHj2tkXTnD
|
||||
Na9raei70fQGtUU3atIkhkY=
|
||||
-----END CERTIFICATE-----
|
||||
|
@ -1,28 +1,27 @@
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCwYp7epz++0QkH
|
||||
JioMD7U7BitLgpcYPi8Cid1l7snt6Kp546iQsDBJ3l8xnRtPU7ANEsjT8KxIHmyw
|
||||
h/NGp94FlOKRw3ahh3yUGtowS9vdHv+S+TAfuj07NjSnKIyv5KnGZJ+fDFl4Q1tT
|
||||
aQJybY1Z4itirL6/2CGEm8g/iYhLNDBsRMfpDpfXe4URyWiM3Rhf7ztqZdveb9al
|
||||
3pAJZIDTLWCFQI1MvQjKamkAQkES/gZj0iUZFwbGJPBj54nkuLFLKedw7DbwgrVg
|
||||
0+n3fQ9b/gQepw5PxQjyobY2DsDgGZV+MFjUmaUTa+XX68SrG4wJ+DwrkdmpHReB
|
||||
vFi1Hg1hAgMBAAECggEAaTCnZkl/7qBjLexIryC/CBBJyaJ70W1kQ7NMYfniWwui
|
||||
f0aRxJgOdD81rjTvkINsPp+xPRQO6oOadjzdjImYEuQTqrJTEUnntbu924eh+2D9
|
||||
Mf2CAanj0mglRnscS9mmljZ0KzoGMX6Z/EhnuS40WiJTlWlH6MlQU/FDnwC6U34y
|
||||
JKy6/jGryfsx+kGU/NRvKSru6JYJWt5v7sOrymHWD62IT59h3blOiP8GMtYKeQlX
|
||||
49om9Mo1VTIFASY3lrxmexbY+6FG8YO+tfIe0tTAiGrkb9Pz6tYbaj9FjEWOv4Vc
|
||||
+3VMBUVdGJjgqvE8fx+/+mHo4Rg69BUPfPSrpEg7sQKBgQDlL85G04VZgrNZgOx6
|
||||
pTlCCl/NkfNb1OYa0BELqWINoWaWQHnm6lX8YjrUjwRpBF5s7mFhguFjUjp/NW6D
|
||||
0EEg5BmO0ePJ3dLKSeOA7gMo7y7kAcD/YGToqAaGljkBI+IAWK5Su5yldrECTQKG
|
||||
YnMKyQ1MWUfCYEwHtPvFvE5aPwKBgQDFBWXekpxHIvt/B41Cl/TftAzE7/f58JjV
|
||||
MFo/JCh9TDcH6N5TMTRS1/iQrv5M6kJSSrHnq8pqDXOwfHLwxetpk9tr937VRzoL
|
||||
CuG1Ar7c1AO6ujNnAEmUVC2DppL/ck5mRPWK/kgLwZSaNcZf8sydRgphsW1ogJin
|
||||
7g0nGbFwXwKBgQCPoZY07Pr1TeP4g8OwWTu5F6dSvdU2CAbtZthH5q98u1n/cAj1
|
||||
noak1Srpa3foGMTUn9CHu+5kwHPIpUPNeAZZBpq91uxa5pnkDMp3UrLIRJ2uZyr8
|
||||
4PxcknEEh8DR5hsM/IbDcrCJQglM19ZtQeW3LKkY4BsIxjDf45ymH407IQKBgE/g
|
||||
Ul6cPfOxQRlNLH4VMVgInSyyxWx1mODFy7DRrgCuh5kTVh+QUVBM8x9lcwAn8V9/
|
||||
nQT55wR8E603pznqY/jX0xvAqZE6YVPcw4kpZcwNwL1RhEl8GliikBlRzUL3SsW3
|
||||
q30AfqEViHPE3XpE66PPo6Hb1ymJCVr77iUuC3wtAoGBAIBrOGunv1qZMfqmwAY2
|
||||
lxlzRgxgSiaev0lTNxDzZkmU/u3dgdTwJ5DDANqPwJc6b8SGYTp9rQ0mbgVHnhIB
|
||||
jcJQBQkTfq6Z0H6OoTVi7dPs3ibQJFrtkoyvYAbyk36quBmNRjVh6rc8468bhXYr
|
||||
v/t+MeGJP/0Zw8v/X2CFll96
|
||||
-----END PRIVATE KEY-----
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEpAIBAAKCAQEAn4LXgTvdUVOCPODVhF0F2rB6vDWHk+YgxhR31fZFnOcxNw+9
|
||||
DIpda+3LSukp/QBn7xrd+cZBTTK9tfDIVDF4e2nnedk0HkHyuKcnyOKUzyFdtE04
|
||||
B8fwFCebM3SF68lynHDN2liUfUD9GkddgPMpHI2BPSBnAivCpj19J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Bw14VCl3Z0719qTbZ+Y9vEcA6z4/u/T654nnddeQu9zUUjYSB4rDIS41EBW7Ft
|
||||
aj9OoZ22B/74MygHJVlW9A8CgYEAmK8p/FQ8JrG93J2Uz1wISAabNM76BVIghryd
|
||||
6MJgLjsKYTnE94ao4NHJZdB71exeRRpD382Ts0BOf1xc/nyzk8QB3y0FpHETuvsH
|
||||
ejwi31wpOl5AXed7DZOgctax5pEjp1vLrSPFnHx4+XN9CEfiLQJR7idG1SpTvBv1
|
||||
kqib8CUCgYBTu9CNS5WfQC/YbKYeU1F6lYRNw79mVmQfAJyL/aUrSGJuUcZo+kZv
|
||||
Rq6QfB7mJDLwniwgVALAGhiDJPagstyajUCSkrV9lDleAPOfb4ep0HQK1GA2Jrs6
|
||||
ldn8NTn7z9pToWbgMyl25vaoSMzIjVJ7uic3LN+iruXpxDpBAFqrfA==
|
||||
-----END RSA PRIVATE KEY-----
|
||||
|
@ -194,15 +194,51 @@ static httpd_handle_t start_webserver(void)
|
||||
httpd_ssl_config_t conf = HTTPD_SSL_CONFIG_DEFAULT();
|
||||
conf.httpd.stack_size = 12000;
|
||||
//pridanie certifikatu do konfiguracie
|
||||
extern const unsigned char cacert_pem_start[] asm("_binary_cacert_pem_start");
|
||||
extern const unsigned char cacert_pem_end[] asm("_binary_cacert_pem_end");
|
||||
conf.cacert_pem = cacert_pem_start;
|
||||
conf.cacert_len = cacert_pem_end - cacert_pem_start;
|
||||
unsigned char *cacert_pem_start = calloc(1200,sizeof(unsigned char));//[1025];
|
||||
//memset(cacert_pem_start,'\0',1025);
|
||||
//char line_buffer[66];
|
||||
FILE* fd = fopen("/spiffs/server.crt", "r");
|
||||
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
|
||||
extern const unsigned char prvtkey_pem_start[] asm("_binary_prvtkey_pem_start");
|
||||
extern const unsigned char prvtkey_pem_end[] asm("_binary_prvtkey_pem_end");
|
||||
unsigned char *prvtkey_pem_start =calloc(1800,sizeof(unsigned char));
|
||||
|
||||
//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_len = prvtkey_pem_end - prvtkey_pem_start;
|
||||
conf.prvtkey_len = size+1;
|
||||
//vytvorenie HTTP + SSL servera
|
||||
esp_err_t ret = httpd_ssl_start(&server, &conf);
|
||||
if (ESP_OK != ret) {
|
||||
|
10
main/main.c
10
main/main.c
@ -177,9 +177,13 @@ void app_main(void)
|
||||
|
||||
|
||||
|
||||
read_file("/spiffs/keyfile.key");
|
||||
read_file("/spiffs/ca.crt");
|
||||
read_file("/spiffs/user.crt");
|
||||
//read_file("/spiffs/keyfile.key");
|
||||
read_file("/spiffs/ca.crt");
|
||||
read_file("/spiffs/server.crt");
|
||||
read_file("/spiffs/server_key.key");
|
||||
read_file("/spiffs/serial.txt");
|
||||
|
||||
|
||||
/* Prompt to be printed before each line.
|
||||
* This can be customized, made dynamic, etc.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user