Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b0f8b4bb authored by Chad Brubaker's avatar Chad Brubaker
Browse files

Fix directory check in UserCertificateSource

If the user has not added any CAs to the user trust store the user-added
directory will not have been created.

Change-Id: I8b5f73af3c0761c56969874231004fedbf7badda
parent 35de8d6d
Loading
Loading
Loading
Loading
+14 −15
Original line number Diff line number Diff line
@@ -62,11 +62,9 @@ public class UserCertificateSource implements CertificateSource {
            }
            final File configDir = Environment.getUserConfigDirectory(UserHandle.myUserId());
            final File userCaDir = new File(configDir, "cacerts-added");
            if (!userCaDir.isDirectory()) {
                throw new AssertionError(userCaDir + " is not a directory");
            }

            Set<X509Certificate> userCerts = new ArraySet<X509Certificate>();
            // If the user hasn't added any certificates the directory may not exist.
            if (userCaDir.isDirectory()) {
                for (String caFile : userCaDir.list()) {
                    InputStream is = null;
                    try {
@@ -80,6 +78,7 @@ public class UserCertificateSource implements CertificateSource {
                        IoUtils.closeQuietly(is);
                    }
                }
            }
            mUserCerts = userCerts;
            return mUserCerts;
        }