Skip to content

Commit 683c2f7

Browse files
authored
Merge pull request #94 from NationalAssociationOfRealtors/fix-cacert
Update CACert handling
2 parents f3e7ab0 + fbd5031 commit 683c2f7

File tree

5 files changed

+31
-12
lines changed

5 files changed

+31
-12
lines changed

project/librets/include/librets/CurlHttpClient.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,18 @@ class CurlHttpClient : public RetsHttpClient
106106
*/
107107
virtual void SetTimeout(int seconds);
108108

109+
/**
110+
* Get the path to the CACert.pem file
111+
* @return A string containing the path to cacert.pem
112+
*/
113+
virtual std::string GetCACertPath() { return mCACertPath;};
114+
115+
/**
116+
* Set the path to the CACert.pem file
117+
* @param A string containing the path to cacert.pem
118+
*/
119+
virtual void SetCACertPath(std::string cacert_path) {mCACertPath = cacert_path;};
120+
109121
private:
110122

111123
static size_t StaticWriteData(char * buffer, size_t size, size_t nmemb,
@@ -131,6 +143,8 @@ class CurlHttpClient : public RetsHttpClient
131143

132144
bool mLogging;
133145

146+
std::string mCACertPath;
147+
134148
std::string mUrl;
135149

136150
std::string mUserName;

project/librets/src/CurlHttpClient.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ CurlHttpClient::CurlHttpClient()
4343
*/
4444
curl_global_init(CURL_GLOBAL_ALL);
4545

46+
mCACertPath = "cacert.pem";
4647
mFlags = 0;
4748
mLogger = NullHttpLogger::GetInstance();
4849
mLogging = false;
@@ -235,7 +236,7 @@ RetsHttpResponsePtr CurlHttpClient::StartRequest(RetsHttpRequest * request)
235236
curlEasy->SetWriteFunction(CurlHttpClient::StaticWriteData);
236237
curlEasy->SetWriteHeaderData(client);
237238
curlEasy->SetWriteHeaderFunction(CurlHttpClient::StaticWriteHeader);
238-
curlEasy->SetCAInfo("cacert.pem");
239+
curlEasy->SetCAInfo(mCACertPath);
239240

240241
if (mFlags & RetsSession::MODE_NO_SSL_VERIFY)
241242
curlEasy->SetSSLVerify(false);

project/librets/test/src/PayloadListResultSetTest.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ void CLASS::testUTF8Response()
230230
* This represents "nunez" with utf8 characters for the accented "u",
231231
* and the "enyay".
232232
*/
233-
const char nunez [] = {0x4e, 0xc3, 0xba, 0xc3, 0xb1, 0x65, 0x7a, 0x00};
233+
unsigned char nunez [] = {0x4e, 0xc3, 0xba, 0xc3, 0xb1, 0x65, 0x7a};
234+
std::string s_nunez(nunez, nunez + sizeof(nunez) / sizeof(nunez[0]));
234235

235236
resultSet.SetEncoding(RETS_XML_DEFAULT_ENCODING);
236237
try
@@ -265,8 +266,8 @@ void CLASS::testUTF8Response()
265266
ASSERT_STRING_EQUAL("AG000001", resultSet.GetString(0));
266267
ASSERT_STRING_EQUAL("Carlos", resultSet.GetString("FirstName"));
267268
ASSERT_STRING_EQUAL("Carlos", resultSet.GetString(1));
268-
ASSERT_STRING_EQUAL(nunez, resultSet.GetString("LastName"));
269-
ASSERT_STRING_EQUAL(nunez, resultSet.GetString(2));
269+
ASSERT_STRING_EQUAL(s_nunez, resultSet.GetString("LastName"));
270+
ASSERT_STRING_EQUAL(s_nunez, resultSet.GetString(2));
270271

271272
CPPUNIT_ASSERT(!resultSet.HasNext());
272273
}

project/librets/test/src/SearchResultSetTest.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,8 @@ void CLASS::testExtendedCharResponse()
282282
* This represents "nunez" with extended characters for the accented "u",
283283
* and the "enyay".
284284
*/
285-
const char nunez [] = {0x4e, 0xc2, 0x9c, 0xc2, 0x96, 0x65, 0x7a, 0x00};
285+
unsigned char nunez [] = {0x4e, 0xc2, 0x9c, 0xc2, 0x96, 0x65, 0x7a};
286+
std::string s_nunez(nunez, nunez + sizeof(nunez) / sizeof(nunez[0]));
286287

287288
resultSet.SetEncoding(RETS_XML_DEFAULT_ENCODING);
288289
try
@@ -315,8 +316,8 @@ void CLASS::testExtendedCharResponse()
315316
ASSERT_STRING_EQUAL("AG000001", resultSet.GetString(0));
316317
ASSERT_STRING_EQUAL("Carlos", resultSet.GetString("FirstName"));
317318
ASSERT_STRING_EQUAL("Carlos", resultSet.GetString(1));
318-
ASSERT_STRING_EQUAL(nunez, resultSet.GetString("LastName"));
319-
ASSERT_STRING_EQUAL(nunez, resultSet.GetString(2));
319+
ASSERT_STRING_EQUAL(s_nunez, resultSet.GetString("LastName"));
320+
ASSERT_STRING_EQUAL(s_nunez, resultSet.GetString(2));
320321

321322
CPPUNIT_ASSERT(!resultSet.HasNext());
322323
}
@@ -400,7 +401,8 @@ void CLASS::testUTF8Response()
400401
* This represents "nunez" with utf8 characters for the accented "u",
401402
* and the "enyay".
402403
*/
403-
const char nunez [] = {0x4e, 0xc3, 0xba, 0xc3, 0xb1, 0x65, 0x7a, 0x00};
404+
unsigned const char nunez [] = {0x4e, 0xc3, 0xba, 0xc3, 0xb1, 0x65, 0x7a};
405+
std::string s_nunez(nunez, nunez + sizeof(nunez) / sizeof(nunez[0]));
404406

405407
resultSet.SetEncoding(RETS_XML_DEFAULT_ENCODING);
406408
try
@@ -432,8 +434,8 @@ void CLASS::testUTF8Response()
432434
ASSERT_STRING_EQUAL("AG000001", resultSet.GetString(0));
433435
ASSERT_STRING_EQUAL("Carlos", resultSet.GetString("FirstName"));
434436
ASSERT_STRING_EQUAL("Carlos", resultSet.GetString(1));
435-
ASSERT_STRING_EQUAL(nunez, resultSet.GetString("LastName"));
436-
ASSERT_STRING_EQUAL(nunez, resultSet.GetString(2));
437+
ASSERT_STRING_EQUAL(s_nunez, resultSet.GetString("LastName"));
438+
ASSERT_STRING_EQUAL(s_nunez, resultSet.GetString(2));
437439

438440
CPPUNIT_ASSERT(!resultSet.HasNext());
439441
}

project/librets/test/src/XmlMetadataParserTest.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,8 @@ void CLASS::testExtendedCharacter()
268268
* This represents "nunez" with extended characters for the accented "u",
269269
* and the "enyay".
270270
*/
271-
const char nunez [] = {0x4e, 0xc2, 0x9c, 0xc2, 0x96, 0x65, 0x7a, 0x00};
271+
unsigned char nunez [] = {0x4e, 0xc2, 0x9c, 0xc2, 0x96, 0x65, 0x7a,};
272+
std::string s_nunez(nunez, nunez + sizeof(nunez) / sizeof(nunez[0]));
272273

273274
mParser->SetEncoding(RETS_XML_DEFAULT_ENCODING);
274275

@@ -298,7 +299,7 @@ void CLASS::testExtendedCharacter()
298299
element->GetStringAttribute("StandardName"));
299300
ASSERT_STRING_EQUAL("Single Family",
300301
element->GetStringAttribute("VisibleName"));
301-
ASSERT_STRING_EQUAL(nunez,
302+
ASSERT_STRING_EQUAL(s_nunez,
302303
element->GetStringAttribute("Description"));
303304
ASSERT_STRING_EQUAL("100.00.001",
304305
element->GetStringAttribute("TableVersion"));

0 commit comments

Comments
 (0)