Also print OpenSSL command line to debug the server

In debug mode, print the OpenSSL command line needed to connect to a
luksrku server.
This commit is contained in:
Johannes Bauer 2019-10-23 16:03:58 +02:00
parent 603e63876f
commit c89ff552d4
3 changed files with 15 additions and 0 deletions

View File

@ -439,6 +439,14 @@ static enum cmd_returncode_t cmd_rawdump(struct editor_context_t *ctx, const cha
for (unsigned int i = 0; i < ctx->keydb->host_count; i++) {
struct host_entry_t *host = &ctx->keydb->hosts[i];
fprintf(stderr, "Host %d:\n", i);
{
char host_uuid[ASCII_UUID_BUFSIZE];
sprintf_uuid(host_uuid, host->host_uuid);
char hex_psk[(PSK_SIZE_BYTES * 2) + 1];
sprintf_hex(hex_psk, host->tls_psk, PSK_SIZE_BYTES);
fprintf(stderr, "openssl s_client -connect 127.0.0.1:23170 -psk %s -psk_identity %s -curves X448:X25519 -ciphersuites TLS_CHACHA20_POLY1305_SHA256:TLS_AES_256_GCM_SHA384 -tls1_3\n", hex_psk, host_uuid);
}
dump_hexline(stderr, " host_uuid ", host->host_uuid, sizeof(host->host_uuid), false);
dump_hexline(stderr, " host_name ", host->host_name, sizeof(host->host_name), true);
dump_hexline(stderr, " tls_psk ", host->tls_psk, sizeof(host->tls_psk), false);

6
util.c
View File

@ -54,6 +54,12 @@ void dump_hex_long(FILE *f, const void *vdata, unsigned int length) {
}
}
void sprintf_hex(char *dest, const uint8_t *data, unsigned int length) {
for (unsigned int i = 0; i < length; i++) {
sprintf(dest + (2 * i), "%02x", data[i]);
}
}
void dump_hex(FILE *f, const void *vdata, unsigned int length, bool use_ascii) {
const uint8_t *data = (const uint8_t*)vdata;
for (unsigned int i = 0; i < length; i++) {

1
util.h
View File

@ -33,6 +33,7 @@
/*************** AUTO GENERATED SECTION FOLLOWS ***************/
bool query_passphrase(const char *prompt, char *passphrase, unsigned int passphrase_maxsize);
void dump_hex_long(FILE *f, const void *vdata, unsigned int length);
void sprintf_hex(char *dest, const uint8_t *data, unsigned int length);
void dump_hex(FILE *f, const void *vdata, unsigned int length, bool use_ascii);
void dump_hexline(FILE *f, const char *prefix, const void *vdata, unsigned int length, bool use_ascii);
bool is_hex(const char *str, int length);