Skip to content

Commit 9e3eee1

Browse files
Fix existing tests
1 parent 367dd5a commit 9e3eee1

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

tests/api.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,15 @@ static int sftpUserAuth(byte authType, WS_UserAuthData* authData, void* ctx)
11581158
return ret;
11591159
}
11601160

1161+
static int AcceptAnyServerHostKey(const byte* pubKey, word32 pubKeySz,
1162+
void* ctx)
1163+
{
1164+
(void)pubKey;
1165+
(void)pubKeySz;
1166+
(void)ctx;
1167+
return 0;
1168+
}
1169+
11611170
/* performs connection to port, sets WOLFSSH_CTX and WOLFSSH on success
11621171
* caller needs to free ctx and ssh when done
11631172
*/
@@ -1180,6 +1189,7 @@ static void sftp_client_connect(WOLFSSH_CTX** ctx, WOLFSSH** ssh, int port)
11801189
return;
11811190
}
11821191

1192+
wolfSSH_CTX_SetPublicKeyCheck(*ctx, AcceptAnyServerHostKey);
11831193
wolfSSH_SetUserAuth(*ctx, sftpUserAuth);
11841194
*ssh = wolfSSH_new(*ctx);
11851195
if (*ssh == NULL) {
@@ -1888,6 +1898,7 @@ static void keyboard_client_connect(WOLFSSH_CTX** ctx, WOLFSSH** ssh, int port)
18881898
return;
18891899
}
18901900

1901+
wolfSSH_CTX_SetPublicKeyCheck(*ctx, AcceptAnyServerHostKey);
18911902
wolfSSH_SetUserAuth(*ctx, keyboardUserAuth);
18921903
*ssh = wolfSSH_new(*ctx);
18931904
if (*ssh == NULL) {

tests/auth.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,15 @@ static THREAD_RETURN WOLFSSH_THREAD pubkey_server_thread(void* args)
549549
WOLFSSL_RETURN_FROM_THREAD(0);
550550
}
551551

552+
static int AcceptAnyServerHostKey(const byte* pubKey, word32 pubKeySz,
553+
void* ctx)
554+
{
555+
(void)pubKey;
556+
(void)pubKeySz;
557+
(void)ctx;
558+
return 0;
559+
}
560+
552561
/* Run one pubkey auth attempt.
553562
* sCtx – server context (authorised key hash)
554563
* cCtx – client context (key material to present)
@@ -578,6 +587,7 @@ static int run_pubkey_test(PubkeyServerCtx* sCtx, PubkeyClientCtx* cCtx,
578587

579588
clientCtx = wolfSSH_CTX_new(WOLFSSH_ENDPOINT_CLIENT, NULL);
580589
AssertNotNull(clientCtx);
590+
wolfSSH_CTX_SetPublicKeyCheck(clientCtx, AcceptAnyServerHostKey);
581591
wolfSSH_SetUserAuth(clientCtx, clientPubkeyUserAuth);
582592

583593
clientSsh = wolfSSH_new(clientCtx);
@@ -977,6 +987,7 @@ static int basic_client_connect(WOLFSSH_CTX** ctx, WOLFSSH** ssh, int port)
977987
return WS_BAD_ARGUMENT;
978988
}
979989

990+
wolfSSH_CTX_SetPublicKeyCheck(*ctx, AcceptAnyServerHostKey);
980991
wolfSSH_SetUserAuth(*ctx, keyboardUserAuth);
981992
*ssh = wolfSSH_new(*ctx);
982993
if (*ssh == NULL) {

0 commit comments

Comments
 (0)