Implemented initial SSH support. Memory pressure too high for HTTPS and
SSH. Dirty commit.
This commit is contained in:
+24
-8
@@ -1,5 +1,5 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-only */
|
||||
/* UART0 HTTPS lifecycle, credentials, certificate, and recovery commands. */
|
||||
/* UART0 HTTPS lifecycle, shared credentials, certificate, and recovery commands. */
|
||||
|
||||
#include "web_console.h"
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "esp_console.h"
|
||||
#include "secure_random.h"
|
||||
#include "ssh_transport.h"
|
||||
#include "web_security.h"
|
||||
#include "web_serial_transport.h"
|
||||
#include "web_server.h"
|
||||
@@ -52,7 +53,7 @@ static int show_status(void)
|
||||
(unsigned int)snapshot.port,
|
||||
esp_err_to_name(snapshot.last_error));
|
||||
if (security_error == ESP_OK) {
|
||||
printf("Authentication: HTTP Basic over TLS, username=%.*s, material=ready\n",
|
||||
printf("Authentication: HTTP Basic over TLS, username=%.*s, shared with SSH\n",
|
||||
(int)username_length, username);
|
||||
} else {
|
||||
printf("Authentication material unavailable: %s; use 'web reset --force' to replace it.\n",
|
||||
@@ -167,7 +168,7 @@ static int show_credentials(void)
|
||||
credentials.username);
|
||||
printf("Password: %.*s\n", (int)credentials.password_length,
|
||||
credentials.password);
|
||||
printf("These credentials protect HTTPS only. Keep them private.\n");
|
||||
printf("These credentials protect HTTPS and SSH. Keep them private.\n");
|
||||
secure_wipe(&credentials, sizeof(credentials));
|
||||
return 0;
|
||||
}
|
||||
@@ -231,11 +232,16 @@ static int rotate_credentials(void)
|
||||
return 1;
|
||||
}
|
||||
|
||||
esp_err_t revoke_error = web_serial_transport_revoke_sessions();
|
||||
printf("Web credentials rotated and persisted. Existing Basic credentials are now invalid.\n");
|
||||
if (revoke_error != ESP_OK && revoke_error != ESP_ERR_INVALID_STATE) {
|
||||
esp_err_t web_revoke_error = web_serial_transport_revoke_sessions();
|
||||
esp_err_t ssh_revoke_error = ssh_transport_revoke_sessions();
|
||||
printf("Administrative credentials rotated and persisted. Existing HTTPS and SSH credentials are now invalid.\n");
|
||||
if (web_revoke_error != ESP_OK && web_revoke_error != ESP_ERR_INVALID_STATE) {
|
||||
printf("Warning: existing WebSocket sessions could not be revoked: %s\n",
|
||||
esp_err_to_name(revoke_error));
|
||||
esp_err_to_name(web_revoke_error));
|
||||
}
|
||||
if (ssh_revoke_error != ESP_OK && ssh_revoke_error != ESP_ERR_INVALID_STATE) {
|
||||
printf("Warning: existing SSH sessions could not be revoked: %s\n",
|
||||
esp_err_to_name(ssh_revoke_error));
|
||||
}
|
||||
printf("Username: %.*s\nPassword: %.*s\n",
|
||||
(int)credentials.username_length, credentials.username,
|
||||
@@ -272,7 +278,17 @@ static int reset_material(void)
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("Web credentials, certificate, and private key replaced and persisted.\n");
|
||||
esp_err_t web_revoke_error = web_serial_transport_revoke_sessions();
|
||||
esp_err_t ssh_revoke_error = ssh_transport_revoke_sessions();
|
||||
printf("Administrative credentials, HTTPS certificate, and HTTPS private key replaced and persisted.\n");
|
||||
if (web_revoke_error != ESP_OK && web_revoke_error != ESP_ERR_INVALID_STATE) {
|
||||
printf("Warning: existing WebSocket sessions could not be revoked: %s\n",
|
||||
esp_err_to_name(web_revoke_error));
|
||||
}
|
||||
if (ssh_revoke_error != ESP_OK && ssh_revoke_error != ESP_ERR_INVALID_STATE) {
|
||||
printf("Warning: existing SSH sessions could not be revoked: %s\n",
|
||||
esp_err_to_name(ssh_revoke_error));
|
||||
}
|
||||
printf("Username: %.*s\nPassword: %.*s\n",
|
||||
(int)credentials.username_length, credentials.username,
|
||||
(int)credentials.password_length, credentials.password);
|
||||
|
||||
Reference in New Issue
Block a user