@@ -77,6 +77,9 @@ struct WOLFSSHD_CONFIG {
7777 char * authKeysFile ;
7878 char * forceCmd ;
7979 char * pidFile ;
80+ char * winUserStores ;
81+ char * winUserDwFlags ;
82+ char * winUserPvPara ;
8083 WOLFSSHD_CONFIG * next ; /* next config in list */
8184 long loginTimer ;
8285 word16 port ;
@@ -88,6 +91,7 @@ struct WOLFSSHD_CONFIG {
8891 byte authKeysFileSet :1 ; /* if not set then no explicit authorized keys */
8992 byte strictModes :1 ; /* enforce file permission/ownership checks */
9093 byte useSystemCA :1 ;
94+ byte useUserCAStore :1 ;
9195};
9296
9397/* Maximum depth of nested Include directives. Bounds the recursion
@@ -360,6 +364,9 @@ void wolfSSHD_ConfigFree(WOLFSSHD_CONFIG* conf)
360364 FreeString (& current -> forceCmd , heap );
361365 FreeString (& current -> usrAppliesTo , heap );
362366 FreeString (& current -> groupAppliesTo , heap );
367+ FreeString (& current -> winUserStores , heap );
368+ FreeString (& current -> winUserDwFlags , heap );
369+ FreeString (& current -> winUserPvPara , heap );
363370
364371 WFREE (current , heap , DYNTYPE_SSHD );
365372 current = next ;
@@ -401,9 +408,13 @@ enum {
401408 OPT_PUBKEY_AUTH = 24 ,
402409 OPT_STRICT_MODES = 25 ,
403410 OPT_TRUSTED_SYSTEM_CA_KEYS = 26 ,
411+ OPT_TRUSTED_USER_CA_STORE = 27 ,
412+ OPT_WIN_USER_STORES = 28 ,
413+ OPT_WIN_USER_DW_FLAGS = 29 ,
414+ OPT_WIN_USER_PV_PARA = 30
404415};
405416enum {
406- NUM_OPTIONS = 27
417+ NUM_OPTIONS = 31
407418};
408419
409420static const CONFIG_OPTION options [NUM_OPTIONS ] = {
@@ -434,6 +445,10 @@ static const CONFIG_OPTION options[NUM_OPTIONS] = {
434445 {OPT_PIDFILE , "PidFile" },
435446 {OPT_BANNER , "Banner" },
436447 {OPT_STRICT_MODES , "StrictModes" },
448+ {OPT_TRUSTED_USER_CA_STORE , "TrustedUserCaStore" },
449+ {OPT_WIN_USER_STORES , "WinUserStores" },
450+ {OPT_WIN_USER_DW_FLAGS , "WinUserDwFlags" },
451+ {OPT_WIN_USER_PV_PARA , "WinUserPvPara" },
437452};
438453
439454/* returns WS_SUCCESS on success */
@@ -1279,6 +1294,17 @@ static int HandleConfigOption(WOLFSSHD_CONFIG** conf, int opt,
12791294 break ;
12801295 case OPT_STRICT_MODES :
12811296 ret = HandleStrictModes (* conf , value );
1297+ case OPT_TRUSTED_USER_CA_STORE :
1298+ ret = wolfSSHD_ConfigSetUserCAStore (* conf , value );
1299+ break ;
1300+ case OPT_WIN_USER_STORES :
1301+ ret = wolfSSHD_ConfigSetWinUserStores (* conf , value );
1302+ break ;
1303+ case OPT_WIN_USER_DW_FLAGS :
1304+ ret = wolfSSHD_ConfigSetWinUserDwFlags (* conf , value );
1305+ break ;
1306+ case OPT_WIN_USER_PV_PARA :
1307+ ret = wolfSSHD_ConfigSetWinUserPvPara (* conf , value );
12821308 break ;
12831309 default :
12841310 break ;
@@ -1661,6 +1687,119 @@ int wolfSSHD_ConfigSetSystemCA(WOLFSSHD_CONFIG* conf, const char* value)
16611687 return ret ;
16621688}
16631689
1690+ /* getter function for if using user CA store
1691+ * return 1 if true and 0 if false */
1692+ int wolfSSHD_ConfigGetUserCAStore (const WOLFSSHD_CONFIG * conf )
1693+ {
1694+ if (conf != NULL ) {
1695+ return conf -> useUserCAStore ;
1696+ }
1697+ return 0 ;
1698+ }
1699+
1700+
1701+ /* setter function for if using user CA store
1702+ * 'yes' if true and 'no' if false
1703+ * returns WS_SUCCESS on success */
1704+ int wolfSSHD_ConfigSetUserCAStore (WOLFSSHD_CONFIG * conf , const char * value )
1705+ {
1706+ int ret = WS_SUCCESS ;
1707+
1708+ if (conf != NULL ) {
1709+ if (WSTRCMP (value , "yes" ) == 0 ) {
1710+ wolfSSH_Log (WS_LOG_INFO , "[SSHD] User CA store enabled. Note this "
1711+ "is currently only supported on Windows." );
1712+ conf -> useUserCAStore = 1 ;
1713+ }
1714+ else if (WSTRCMP (value , "no" ) == 0 ) {
1715+ wolfSSH_Log (WS_LOG_INFO , "[SSHD] User CA store disabled" );
1716+ conf -> useUserCAStore = 0 ;
1717+ }
1718+ else {
1719+ wolfSSH_Log (WS_LOG_INFO , "[SSHD] User CA store unexpected flag" );
1720+ ret = WS_FATAL_ERROR ;
1721+ }
1722+ }
1723+
1724+ return ret ;
1725+ }
1726+
1727+ char * wolfSSHD_ConfigGetWinUserStores (WOLFSSHD_CONFIG * conf ) {
1728+ if (conf != NULL ) {
1729+ if (conf -> winUserStores == NULL ) {
1730+ /* If no value was specified, default to CERT_STORE_PROV_SYSTEM */
1731+ CreateString (& conf -> winUserStores , "CERT_STORE_PROV_SYSTEM" ,
1732+ (int )WSTRLEN ("CERT_STORE_PROV_SYSTEM" ), conf -> heap );
1733+ }
1734+
1735+ return conf -> winUserStores ;
1736+ }
1737+
1738+ return NULL ;
1739+ }
1740+
1741+ int wolfSSHD_ConfigSetWinUserStores (WOLFSSHD_CONFIG * conf , const char * value ) {
1742+ int ret = WS_SUCCESS ;
1743+
1744+ if (conf == NULL ) {
1745+ ret = WS_BAD_ARGUMENT ;
1746+ }
1747+
1748+ ret = CreateString (& conf -> winUserStores , value , (int )WSTRLEN (value ), conf -> heap );
1749+
1750+ return ret ;
1751+ }
1752+
1753+ char * wolfSSHD_ConfigGetWinUserDwFlags (WOLFSSHD_CONFIG * conf ) {
1754+ if (conf != NULL ) {
1755+ if (conf -> winUserDwFlags == NULL ) {
1756+ /* If no value was specified, default to CERT_SYSTEM_STORE_CURRENT_USER */
1757+ CreateString (& conf -> winUserDwFlags , "CERT_SYSTEM_STORE_CURRENT_USER" ,
1758+ (int )WSTRLEN ("CERT_SYSTEM_STORE_CURRENT_USER" ), conf -> heap );
1759+ }
1760+
1761+ return conf -> winUserDwFlags ;
1762+ }
1763+
1764+ return NULL ;
1765+ }
1766+
1767+ int wolfSSHD_ConfigSetWinUserDwFlags (WOLFSSHD_CONFIG * conf , const char * value ) {
1768+ int ret = WS_SUCCESS ;
1769+
1770+ if (conf == NULL ) {
1771+ ret = WS_BAD_ARGUMENT ;
1772+ }
1773+
1774+ ret = CreateString (& conf -> winUserDwFlags , value , (int )WSTRLEN (value ), conf -> heap );
1775+
1776+ return ret ;
1777+ }
1778+
1779+ char * wolfSSHD_ConfigGetWinUserPvPara (WOLFSSHD_CONFIG * conf ) {
1780+ if (conf != NULL ) {
1781+ if (conf -> winUserPvPara == NULL ) {
1782+ /* If no value was specified, default to MY */
1783+ CreateString (& conf -> winUserPvPara , "MY" , (int )WSTRLEN ("MY" ), conf -> heap );
1784+ }
1785+
1786+ return conf -> winUserPvPara ;
1787+ }
1788+
1789+ return NULL ;
1790+ }
1791+
1792+ int wolfSSHD_ConfigSetWinUserPvPara (WOLFSSHD_CONFIG * conf , const char * value ) {
1793+ int ret = WS_SUCCESS ;
1794+
1795+ if (conf == NULL ) {
1796+ ret = WS_BAD_ARGUMENT ;
1797+ }
1798+
1799+ ret = CreateString (& conf -> winUserPvPara , value , (int )WSTRLEN (value ), conf -> heap );
1800+
1801+ return ret ;
1802+ }
16641803
16651804char * wolfSSHD_ConfigGetUserCAKeysFile (const WOLFSSHD_CONFIG * conf )
16661805{
0 commit comments