@@ -89,6 +89,7 @@ struct WOLFSSHD_CONFIG {
8989 byte permitRootLogin :1 ;
9090 byte permitEmptyPasswords :1 ;
9191 byte authKeysFileSet :1 ; /* if not set then no explicit authorized keys */
92+ byte useSystemCA :1 ;
9293};
9394
9495int CountWhitespace (const char * in , int inSz , byte inv );
@@ -348,10 +349,11 @@ enum {
348349 OPT_FORCE_CMD = 19 ,
349350 OPT_HOST_CERT = 20 ,
350351 OPT_TRUSTED_USER_CA_KEYS = 21 ,
351- OPT_PIDFILE = 22 ,
352+ OPT_TRUSTED_SYSTEM_CA_KEYS = 22 ,
353+ OPT_PIDFILE = 23 ,
352354};
353355enum {
354- NUM_OPTIONS = 23
356+ NUM_OPTIONS = 24
355357};
356358
357359static const CONFIG_OPTION options [NUM_OPTIONS ] = {
@@ -377,6 +379,7 @@ static const CONFIG_OPTION options[NUM_OPTIONS] = {
377379 {OPT_FORCE_CMD , "ForceCommand" },
378380 {OPT_HOST_CERT , "HostCertificate" },
379381 {OPT_TRUSTED_USER_CA_KEYS , "TrustedUserCAKeys" },
382+ {OPT_TRUSTED_SYSTEM_CA_KEYS , "TrustedSystemCAKeys" },
380383 {OPT_PIDFILE , "PidFile" },
381384};
382385
@@ -1019,6 +1022,9 @@ static int HandleConfigOption(WOLFSSHD_CONFIG** conf, int opt,
10191022 /* TODO: Add logic to check if file exists? */
10201023 ret = wolfSSHD_ConfigSetUserCAKeysFile (* conf , value );
10211024 break ;
1025+ case OPT_TRUSTED_SYSTEM_CA_KEYS :
1026+ ret = wolfSSHD_ConfigSetSystemCA (* conf , value );
1027+ break ;
10221028 case OPT_PIDFILE :
10231029 ret = SetFileString (& (* conf )-> pidFile , value , (* conf )-> heap );
10241030 break ;
@@ -1304,6 +1310,44 @@ char* wolfSSHD_ConfigGetHostCertFile(const WOLFSSHD_CONFIG* conf)
13041310 return ret ;
13051311}
13061312
1313+
1314+ /* getter function for if using system CAs
1315+ * return 1 if true and 0 if false */
1316+ int wolfSSHD_ConfigGetSystemCA (const WOLFSSHD_CONFIG * conf )
1317+ {
1318+ if (conf != NULL ) {
1319+ return conf -> useSystemCA ;
1320+ }
1321+ return 0 ;
1322+ }
1323+
1324+
1325+ /* setter function for if using system CAs
1326+ * 'yes' if true and 'no' if false
1327+ * returns WS_SUCCESS on success */
1328+ int wolfSSHD_ConfigSetSystemCA (WOLFSSHD_CONFIG * conf , const char * value )
1329+ {
1330+ int ret = WS_SUCCESS ;
1331+
1332+ if (conf != NULL ) {
1333+ if (WSTRCMP (value , "yes" ) == 0 ) {
1334+ wolfSSH_Log (WS_LOG_INFO , "[SSHD] System CAs enabled" );
1335+ conf -> useSystemCA = 1 ;
1336+ }
1337+ else if (WSTRCMP (value , "no" ) == 0 ) {
1338+ wolfSSH_Log (WS_LOG_INFO , "[SSHD] System CAs disabled" );
1339+ conf -> useSystemCA = 0 ;
1340+ }
1341+ else {
1342+ wolfSSH_Log (WS_LOG_INFO , "[SSHD] System CAs unexpected flag" );
1343+ ret = WS_FATAL_ERROR ;
1344+ }
1345+ }
1346+
1347+ return ret ;
1348+ }
1349+
1350+
13071351char * wolfSSHD_ConfigGetUserCAKeysFile (const WOLFSSHD_CONFIG * conf )
13081352{
13091353 char * ret = NULL ;
0 commit comments