diff options
author | Hoa V. DINH <dinh.viet.hoa@gmail.com> | 2014-12-10 23:43:01 -0800 |
---|---|---|
committer | Hoa V. DINH <dinh.viet.hoa@gmail.com> | 2014-12-10 23:43:01 -0800 |
commit | d6c39f88b66ad613915b7c9475451f9bbe010046 (patch) | |
tree | e5b39a3a27ad861c6a4e050dc2ebb91f815fe48f /src/core/security | |
parent | f6d2ddffc031d8ff6f912f6c2fcad2b4582816a3 (diff) |
Android: Implemented MCMainThread, implemented certificate verification
Diffstat (limited to 'src/core/security')
-rw-r--r-- | src/core/security/MCCertificateUtils.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/core/security/MCCertificateUtils.cpp b/src/core/security/MCCertificateUtils.cpp index f2345e90..2130714b 100644 --- a/src/core/security/MCCertificateUtils.cpp +++ b/src/core/security/MCCertificateUtils.cpp @@ -19,6 +19,8 @@ #include <openssl/err.h> #endif +#include <dirent.h> + #include "MCLog.h" bool mailcore::checkCertificate(mailstream * stream, String * hostname) @@ -97,6 +99,9 @@ err: X509_STORE * store = NULL; X509_STORE_CTX * storectx = NULL; STACK_OF(X509) * certificates = NULL; + DIR * dir = NULL; + struct dirent * ent = NULL; + FILE * f = NULL; int status; carray * cCerts = mailstream_get_certificate_chain(stream); @@ -127,6 +132,25 @@ err: previousCert = nextCert; } CertCloseStore(systemStore, 0); +#elif defined(ANDROID) || defined(__ANDROID__) + dir = opendir("/system/etc/security/cacerts"); + while (ent = readdir(dir)) { + if (ent->d_name[0] == '.') { + continue; + } + char filename[1024]; + snprintf(filename, sizeof(filename), "/system/etc/security/cacerts/%s", ent->d_name); + f = fopen(filename, "rb"); + if (f != NULL) { + X509 * cert = PEM_read_X509(f, NULL, NULL, NULL); + if (cert != NULL) { + X509_STORE_add_cert(store, cert); + X509_free(cert); + } + fclose(f); + } + } + closedir(dir); #endif status = X509_STORE_set_default_paths(store); |