Fixed errors not returning from SSLContext load crt

This commit is contained in:
Fred Nicolson 2017-05-11 14:09:55 +01:00
parent 9646d72e74
commit 60dfd44c0f

View File

@ -53,8 +53,8 @@ namespace fr
*/ */
bool load_ca_certs_from_memory(const std::string &ca_certs) bool load_ca_certs_from_memory(const std::string &ca_certs)
{ {
int error; int error = mbedtls_x509_crt_parse(&cacert, (const unsigned char *)ca_certs.c_str(), ca_certs.size());
if((error = mbedtls_x509_crt_parse(&cacert, (const unsigned char *)ca_certs.c_str(), ca_certs.size()) < 0)) if(error < 0)
{ {
std::cout << "Failed to parse root CA certificates. Parse returned: " << error << std::endl; std::cout << "Failed to parse root CA certificates. Parse returned: " << error << std::endl;
return false; return false;
@ -70,8 +70,8 @@ namespace fr
*/ */
bool load_ca_certs_from_file(const std::string &ca_certs_filepath) bool load_ca_certs_from_file(const std::string &ca_certs_filepath)
{ {
int error; int error = mbedtls_x509_crt_parse_file(&cacert, ca_certs_filepath.c_str());
if((error = mbedtls_x509_crt_parse_file(&cacert, ca_certs_filepath.c_str()) < 0)) if(error < 0)
{ {
std::cout << "Failed to parse root CA certificates. Parse returned: " << error << std::endl; std::cout << "Failed to parse root CA certificates. Parse returned: " << error << std::endl;
return false; return false;