Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TLS_axTLS-Example HTTPSClientExample
CertificateManager.h
00001 #ifndef CERTIFICATE_MANAGER_H 00002 #define CERTIFICATE_MANAGER_H 00003 00004 #include "mbed.h" 00005 #include <vector> 00006 #include <list> 00007 #include <string> 00008 #include "axTLS/ssl/crypto_misc.h " 00009 #include "cert_manager.h" 00010 00011 00012 /** This class is in charge of loading and storing certificates. 00013 00014 Example: 00015 @code 00016 #include "mbed.h" 00017 #include "CertificateManager.h 00018 LocalFileSystem local("/local/"); 00019 00020 int main(void) 00021 { 00022 CertificateManager::add("/local/root.der"); 00023 if(!CertificateManager::load()) 00024 printf("Error while loading certificates\n"); 00025 00026 return 0; 00027 } 00028 @endcode 00029 */ 00030 class CertificateManager 00031 { 00032 public : 00033 00034 friend char is_precomputed(void); 00035 friend PrecomputedCertificate get_precomputed_cert(char *cert_dn[], char *ca_cert_dn[]); 00036 friend X509_CTX* get_cert(char *ca_cert_dn[]); 00037 00038 /** Add a certificate to load. 00039 00040 \param fileName Certificate's filename. 00041 \note This function does not load the certificate 00042 and does not check if the file exists. 00043 */ 00044 static void add(const char *fileName); 00045 00046 /** Load certificates. 00047 00048 \param precompute Tells the certificate manager how to load 00049 certificates. 00050 \return True if certificates were loaded with 00051 success, false otherwise. 00052 00053 \note If the loading fails, everything is cleared. So, 00054 you have to add again all certificates you need. 00055 */ 00056 static bool load(const bool precompute = false); 00057 00058 /** Clear everything. 00059 \note This function should be called once a TLS 00060 connection is established with success. 00061 */ 00062 static void clear(); 00063 00064 private : 00065 00066 CertificateManager(); 00067 ~CertificateManager(); 00068 static CertificateManager& instance(); 00069 00070 bool loadCertificates(); 00071 bool loadPrecomputeCertificates(); 00072 bool check(X509_CTX *cert1, X509_CTX* cert2); 00073 00074 std::list<std::string> files; 00075 X509_CTX *certs; 00076 std::vector<PrecomputedCertificate> precomputedCerts; 00077 }; 00078 00079 00080 #endif 00081
Generated on Wed Jul 13 2022 19:30:07 by
1.7.2