Skip to content

Commit da9ef19

Browse files
add Windows cert store use with signing and add example arguments
add Windows cert store test case make windows cert feature default disabled and simplify macro guard additional unit tests, advertise x509 and pubkey, use CN to match username, build check for WOLFSSL_SYS_CA_CERTS, fix for CM ref count additional build test, uniform enum name, fail on unkown cert store ecc curve, tie in of loading whole cert store for sys CA's
1 parent 1e05ae3 commit da9ef19

24 files changed

Lines changed: 3098 additions & 285 deletions

File tree

.github/workflows/windows-cert-store-test.yml

Lines changed: 731 additions & 0 deletions
Large diffs are not rendered by default.

apps/wolfsshd/auth.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@
5555
#include <wolfssl/wolfcrypt/coding.h>
5656
#include <wolfssl/wolfcrypt/asn_public.h>
5757

58-
#ifdef WOLFSSL_FPKI
58+
#if defined(WOLFSSL_FPKI) || defined(_WIN32)
59+
/* Used to bind a client certificate to the requested user name: by UPN
60+
* with FPKI, by subject CN on Windows builds without FPKI. */
5961
#include <wolfssl/wolfcrypt/asn.h>
6062
#endif
6163

@@ -2597,10 +2599,11 @@ static int RequestAuthentication(WS_UserAuthData* authData,
25972599
ret = WOLFSSH_USERAUTH_REJECTED;
25982600
}
25992601

2600-
#ifdef WOLFSSL_FPKI
2602+
#if defined(WOLFSSL_FPKI) || defined(_WIN32)
26012603
if (ret == WOLFSSH_USERAUTH_SUCCESS &&
26022604
authData->type == WOLFSSH_USERAUTH_PUBLICKEY) {
2603-
/* compare user name to UPN in certificate */
2605+
/* Bind the certificate to the requested user name via UPN with FPKI or
2606+
* CN without FPKI. */
26042607
if (authData->sf.publicKey.isCert) {
26052608
#ifdef WOLFSSH_SMALL_STACK
26062609
DecodedCert* dCert;
@@ -2627,6 +2630,7 @@ static int RequestAuthentication(WS_UserAuthData* authData,
26272630
}
26282631
else {
26292632
int usrMatch = 0;
2633+
#ifdef WOLFSSL_FPKI
26302634
int upnRealmUnchecked = 0;
26312635
DNS_entry* current = dCert->altNames;
26322636
const char* upnDomains =
@@ -2655,6 +2659,15 @@ static int RequestAuthentication(WS_UserAuthData* authData,
26552659
wolfSSH_Log(WS_LOG_WARN, "[SSHD] AuthorizedUPNDomains "
26562660
"not set; certificate UPN domain is not checked");
26572661
}
2662+
#else
2663+
/* Without FPKI compare subject CN with user name */
2664+
if (dCert->subjectCN != NULL &&
2665+
(int)XSTRLEN(usr) == dCert->subjectCNLen &&
2666+
XSTRNCMP(usr, dCert->subjectCN,
2667+
(size_t)dCert->subjectCNLen) == 0) {
2668+
usrMatch = 1;
2669+
}
2670+
#endif
26582671

26592672
if (usrMatch == 0) {
26602673
wolfSSH_Log(WS_LOG_ERROR, "[SSHD] incorrect user cert "
@@ -2692,7 +2705,9 @@ static int RequestAuthentication(WS_UserAuthData* authData,
26922705
}
26932706
else {
26942707
#ifdef _WIN32
2695-
/* Still need to get users token on Windows */
2708+
/* The UPN/CN-vs-username check above already bound the
2709+
* certificate to the requested user. Still need to get
2710+
* the users token on Windows. */
26962711
wolfSSH_Log(WS_LOG_INFO,
26972712
"[SSHD] Relying on CA for public key check");
26982713
rc = SetupUserTokenWin(usr, &authData->sf.publicKey,

0 commit comments

Comments
 (0)