@@ -2250,6 +2250,25 @@ cacerts_load(Config) ->
22502250 Datadir = proplists :get_value (data_dir , Config ),
22512251 {error , enoent } = public_key :cacerts_load (" /dummy.file" ),
22522252
2253+ % % When no CA certificates can be found (missing bundle or one
2254+ % % without any CA certificates) this should surface as a
2255+ % % {failed_load_cacerts, no_cacerts_found} error through cacerts_get()
2256+ % % and be formattable, not crash the error conversion
2257+ _ = public_key :cacerts_clear (),
2258+ EmptyDir = filename :join (proplists :get_value (priv_dir , Config ),
2259+ " empty_cacerts_dir" ),
2260+ ok = filelib :ensure_path (EmptyDir ),
2261+ {error , no_cacerts_found } = pubkey_os_cacerts :load ([EmptyDir ]),
2262+ application :set_env (public_key , cacerts_path , EmptyDir ),
2263+ try public_key :cacerts_get () of
2264+ _ -> ct :fail (no_cacerts_found_not_raised )
2265+ catch
2266+ error :{failed_load_cacerts , no_cacerts_found } = Error :ST ->
2267+ #{general := _ , reason := _ } =
2268+ pubkey_os_cacerts :format_error (Error , ST )
2269+ end ,
2270+ application :unset_env (public_key , cacerts_path ),
2271+
22532272 % % White box testing of paths loading
22542273 % % TestDirs
22552274 ok = pubkey_os_cacerts :load ([filename :join (Datadir , " non_existing_dir" ),
0 commit comments