Skip to content

Commit 38297a0

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 e02f102 commit 38297a0

24 files changed

Lines changed: 3065 additions & 254 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
@@ -54,7 +54,9 @@
5454
#include <wolfssl/wolfcrypt/error-crypt.h>
5555
#include <wolfssl/wolfcrypt/coding.h>
5656

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

@@ -1728,10 +1730,11 @@ static int RequestAuthentication(WS_UserAuthData* authData,
17281730
ret = WOLFSSH_USERAUTH_REJECTED;
17291731
}
17301732

1731-
#ifdef WOLFSSL_FPKI
1733+
#if defined(WOLFSSL_FPKI) || defined(_WIN32)
17321734
if (ret == WOLFSSH_USERAUTH_SUCCESS &&
17331735
authData->type == WOLFSSH_USERAUTH_PUBLICKEY) {
1734-
/* compare user name to UPN in certificate */
1736+
/* Bind the certificate to the requested user name via UPN with FPKI or
1737+
* CN without FPKI. */
17351738
if (authData->sf.publicKey.isCert) {
17361739
DecodedCert* dCert;
17371740
#ifdef WOLFSSH_SMALL_STACK
@@ -1756,6 +1759,7 @@ static int RequestAuthentication(WS_UserAuthData* authData,
17561759
}
17571760
else {
17581761
int usrMatch = 0;
1762+
#ifdef WOLFSSL_FPKI
17591763
int upnRealmUnchecked = 0;
17601764
DNS_entry* current = dCert->altNames;
17611765
const char* upnDomains =
@@ -1784,6 +1788,15 @@ static int RequestAuthentication(WS_UserAuthData* authData,
17841788
wolfSSH_Log(WS_LOG_WARN, "[SSHD] AuthorizedUPNDomains "
17851789
"not set; certificate UPN domain is not checked");
17861790
}
1791+
#else
1792+
/* Without FPKI compare subject CN with user name */
1793+
if (dCert->subjectCN != NULL &&
1794+
(int)XSTRLEN(usr) == dCert->subjectCNLen &&
1795+
XSTRNCMP(usr, dCert->subjectCN,
1796+
(size_t)dCert->subjectCNLen) == 0) {
1797+
usrMatch = 1;
1798+
}
1799+
#endif
17871800

17881801
if (usrMatch == 0) {
17891802
wolfSSH_Log(WS_LOG_ERROR, "[SSHD] incorrect user cert "
@@ -1821,7 +1834,9 @@ static int RequestAuthentication(WS_UserAuthData* authData,
18211834
}
18221835
else {
18231836
#ifdef _WIN32
1824-
/* Still need to get users token on Windows */
1837+
/* The UPN/CN-vs-username check above already bound the
1838+
* certificate to the requested user. Still need to get
1839+
* the users token on Windows. */
18251840
wolfSSH_Log(WS_LOG_INFO,
18261841
"[SSHD] Relying on CA for public key check");
18271842
rc = SetupUserTokenWin(usr, &authData->sf.publicKey,

0 commit comments

Comments
 (0)