@@ -1498,42 +1498,6 @@ static int tls_config_parse_bool(WINPR_JSON* json, const char* opt)
14981498 return 0 ;
14991499}
15001500
1501- static char * tls_config_read (const char * configfile )
1502- {
1503- char * data = NULL ;
1504- FILE * fp = winpr_fopen (configfile , "r" );
1505- if (!fp )
1506- return NULL ;
1507-
1508- const int rc = fseek (fp , 0 , SEEK_END );
1509- if (rc != 0 )
1510- goto fail ;
1511-
1512- const INT64 size = _ftelli64 (fp );
1513- if (size <= 0 )
1514- goto fail ;
1515-
1516- const int rc2 = fseek (fp , 0 , SEEK_SET );
1517- if (rc2 != 0 )
1518- goto fail ;
1519-
1520- data = calloc ((size_t )size + 1 , sizeof (char ));
1521- if (!data )
1522- goto fail ;
1523-
1524- const size_t read = fread (data , 1 , (size_t )size , fp );
1525- if (read != (size_t )size )
1526- {
1527- free (data );
1528- data = NULL ;
1529- goto fail ;
1530- }
1531-
1532- fail :
1533- fclose (fp );
1534- return data ;
1535- }
1536-
15371501static int tls_config_check_allowed_hashed (const char * configfile , const rdpCertificate * cert ,
15381502 WINPR_JSON * json )
15391503{
@@ -1604,26 +1568,12 @@ static int tls_config_check_certificate(const rdpCertificate* cert, BOOL* pAllow
16041568 WINPR_ASSERT (pAllowUserconfig );
16051569
16061570 int rc = 0 ;
1607- char * configfile = freerdp_GetConfigFilePath (TRUE, "certificates.json" );
1608- WINPR_JSON * json = NULL ;
1609-
1610- if (!configfile )
1611- {
1612- WLog_DBG (TAG , "No configuration file for certificate handling, asking user" );
1613- goto fail ;
1614- }
1571+ const char configfile [] = "certificates.json" ;
1572+ WINPR_JSON * json = freerdp_GetJSONConfigFile (TRUE, configfile );
16151573
1616- char * configdata = tls_config_read (configfile );
1617- if (!configdata )
1618- {
1619- WLog_DBG (TAG , "Configuration file for certificate handling, asking user" );
1620- goto fail ;
1621- }
1622- json = WINPR_JSON_Parse (configdata );
16231574 if (!json )
16241575 {
1625- WLog_DBG (TAG , "No valid configuration file '%s' for certificate handling, asking user" ,
1626- configfile );
1576+ WLog_DBG (TAG , "No or no valid configuration file for certificate handling, asking user" );
16271577 goto fail ;
16281578 }
16291579
@@ -1659,7 +1609,6 @@ static int tls_config_check_certificate(const rdpCertificate* cert, BOOL* pAllow
16591609
16601610 * pAllowUserconfig = (rc == 0 );
16611611 WINPR_JSON_Delete (json );
1662- free (configfile );
16631612 return rc ;
16641613}
16651614
0 commit comments