Browse Source

Merge pull request #1047 from psiori/master

Use caCertificatePemFile in OpenSSL backend
Paul-Louis Ageneau 1 year ago
parent
commit
cafd410f19
1 changed files with 9 additions and 0 deletions
  1. 9 0
      src/impl/verifiedtlstransport.cpp

+ 9 - 0
src/impl/verifiedtlstransport.cpp

@@ -45,6 +45,15 @@ VerifiedTlsTransport::VerifiedTlsTransport(
 		throw;
 	}
 #else
+	if (cacert) {
+		if (cacert->find(PemBeginCertificateTag) == string::npos) {
+			// *cacert is a file path
+			openssl::check(SSL_CTX_load_verify_locations(mCtx, cacert->c_str(), NULL), "Failed to load CA certificate");
+		} else {
+			// *cacert is a PEM content
+			PLOG_WARNING << "CA certificate as PEM is not supported for OpenSSL";
+		}
+	}
 	SSL_set_verify(mSsl, SSL_VERIFY_PEER, NULL);
 	SSL_set_verify_depth(mSsl, 4);
 #endif