Skip to content

Commit 6ba0c2e

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 766e09e commit 6ba0c2e

24 files changed

Lines changed: 3118 additions & 299 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

@@ -2676,10 +2678,11 @@ static int RequestAuthentication(WS_UserAuthData* authData,
26762678
ret = WOLFSSH_USERAUTH_REJECTED;
26772679
}
26782680

2679-
#ifdef WOLFSSL_FPKI
2681+
#if defined(WOLFSSL_FPKI) || defined(_WIN32)
26802682
if (ret == WOLFSSH_USERAUTH_SUCCESS &&
26812683
authData->type == WOLFSSH_USERAUTH_PUBLICKEY) {
2682-
/* compare user name to UPN in certificate */
2684+
/* Bind the certificate to the requested user name via UPN with FPKI or
2685+
* CN without FPKI. */
26832686
if (authData->sf.publicKey.isCert) {
26842687
#ifdef WOLFSSH_SMALL_STACK
26852688
DecodedCert* dCert;
@@ -2706,6 +2709,7 @@ static int RequestAuthentication(WS_UserAuthData* authData,
27062709
}
27072710
else {
27082711
int usrMatch = 0;
2712+
#ifdef WOLFSSL_FPKI
27092713
int upnRealmUnchecked = 0;
27102714
DNS_entry* current = dCert->altNames;
27112715
const char* upnDomains =
@@ -2734,6 +2738,15 @@ static int RequestAuthentication(WS_UserAuthData* authData,
27342738
wolfSSH_Log(WS_LOG_WARN, "[SSHD] AuthorizedUPNDomains "
27352739
"not set; certificate UPN domain is not checked");
27362740
}
2741+
#else
2742+
/* Without FPKI compare subject CN with user name */
2743+
if (dCert->subjectCN != NULL &&
2744+
(int)XSTRLEN(usr) == dCert->subjectCNLen &&
2745+
XSTRNCMP(usr, dCert->subjectCN,
2746+
(size_t)dCert->subjectCNLen) == 0) {
2747+
usrMatch = 1;
2748+
}
2749+
#endif
27372750

27382751
if (usrMatch == 0) {
27392752
wolfSSH_Log(WS_LOG_ERROR, "[SSHD] incorrect user cert "
@@ -2771,7 +2784,9 @@ static int RequestAuthentication(WS_UserAuthData* authData,
27712784
}
27722785
else {
27732786
#ifdef _WIN32
2774-
/* Still need to get users token on Windows */
2787+
/* The UPN/CN-vs-username check above already bound the
2788+
* certificate to the requested user. Still need to get
2789+
* the users token on Windows. */
27752790
wolfSSH_Log(WS_LOG_INFO,
27762791
"[SSHD] Relying on CA for public key check");
27772792
rc = SetupUserTokenWin(usr, &authData->sf.publicKey,

0 commit comments

Comments
 (0)