@@ -68,8 +68,6 @@ static void shutdown_ssl(void)
6868 }
6969}
7070
71- int git_mbedtls__set_cert_location (const char * path , int is_dir );
72-
7371int git_mbedtls_stream_global_init (void )
7472{
7573 int loaded = 0 ;
@@ -148,9 +146,9 @@ int git_mbedtls_stream_global_init(void)
148146
149147 /* load default certificates */
150148 if (crtpath != NULL && stat (crtpath , & statbuf ) == 0 && S_ISREG (statbuf .st_mode ))
151- loaded = (git_mbedtls__set_cert_location (crtpath , 0 ) == 0 );
149+ loaded = (git_mbedtls__set_cert_location (crtpath , NULL ) == 0 );
152150 if (!loaded && crtpath != NULL && stat (crtpath , & statbuf ) == 0 && S_ISDIR (statbuf .st_mode ))
153- loaded = (git_mbedtls__set_cert_location (crtpath , 1 ) == 0 );
151+ loaded = (git_mbedtls__set_cert_location (NULL , crtpath ) == 0 );
154152
155153 return git_runtime_shutdown_register (shutdown_ssl );
156154
@@ -438,23 +436,22 @@ int git_mbedtls_stream_new(
438436 return error ;
439437}
440438
441- int git_mbedtls__set_cert_location (const char * path , int is_dir )
439+ int git_mbedtls__set_cert_location (const char * file , const char * path )
442440{
443441 int ret = 0 ;
444442 char errbuf [512 ];
445443 mbedtls_x509_crt * cacert ;
446444
447- GIT_ASSERT_ARG (path );
445+ GIT_ASSERT_ARG (file || path );
448446
449447 cacert = git__malloc (sizeof (mbedtls_x509_crt ));
450448 GIT_ERROR_CHECK_ALLOC (cacert );
451449
452450 mbedtls_x509_crt_init (cacert );
453- if (is_dir ) {
451+ if (file )
452+ ret = mbedtls_x509_crt_parse_file (cacert , file );
453+ if (ret >= 0 && path )
454454 ret = mbedtls_x509_crt_parse_path (cacert , path );
455- } else {
456- ret = mbedtls_x509_crt_parse_file (cacert , path );
457- }
458455 /* mbedtls_x509_crt_parse_path returns the number of invalid certs on success */
459456 if (ret < 0 ) {
460457 mbedtls_x509_crt_free (cacert );
0 commit comments