This allows testing post-handshake authentication using gnutls-serv.
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
}
}
-int check_command(gnutls_session_t session, const char *str)
+int check_command(gnutls_session_t session, const char *str, unsigned no_cli_cert)
{
size_t len = strnlen(str, 128);
int ret;
} else if (strncmp
(str, "**REAUTH**",
sizeof("**REAUTH**") - 1) == 0) {
+ /* in case we have a re-auth cmd prepare for it */
+ if (no_cli_cert)
+ gnutls_certificate_server_set_request(session, GNUTLS_CERT_REQUIRE);
+
fprintf(stderr,
"*** Sending re-auth request\n");
do {
const char *raw_to_string(const unsigned char *raw, size_t raw_size);
const char *raw_to_hex(const unsigned char *raw, size_t raw_size);
const char *raw_to_base64(const unsigned char *raw, size_t raw_size);
-int check_command(gnutls_session_t session, const char *str);
+int check_command(gnutls_session_t session, const char *str, unsigned no_cli_cert);
int
pin_callback(void *user, int attempt, const char *token_url,
if (http != 0) {
*response = peer_print_info(session, response_length, h);
} else {
+ int ret;
strip(request);
- fprintf(stderr, "received: %s\n", request);
- if (check_command(session, request)) {
+ fprintf(stderr, "received cmd: %s\n", request);
+
+ ret = check_command(session, request, disable_client_cert);
+ if (ret > 0) {
*response = strdup("Successfully executed command\n");
if (*response == NULL) {
fprintf(stderr, "Memory error\n");
}
*response_length = strlen(*response);
return;
+ } else if (ret == 0) {
+ *response = strdup(request);
+ *response_length = ((*response) ? strlen(*response) : 0);
+ } else {
+ do {
+ ret = gnutls_alert_send(session, GNUTLS_AL_FATAL, GNUTLS_A_UNEXPECTED_MESSAGE);
+ } while(ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
}
- *response = strdup(request);
- *response_length = ((*response) ? strlen(*response) : 0);
}
return;
#include "serv-args.h"
#include "list.h"
+extern int disable_client_cert;
+
typedef struct {
gnutls_session_t session;
int fd;
sequence[3], sequence[4], sequence[5],
sequence[6], sequence[7], buffer);
- if (check_command(session, buffer) == 0) {
+ if (check_command(session, buffer, disable_client_cert) == 0) {
/* reply back */
ret =
gnutls_record_send(session, buffer,