Skip to content

Commit

Permalink
Merge pull request #94 from NationalAssociationOfRealtors/fix-cacert
Browse files Browse the repository at this point in the history
Update CACert handling
  • Loading branch information
jazzklein authored Aug 12, 2020
2 parents f3e7ab0 + fbd5031 commit 683c2f7
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 12 deletions.
14 changes: 14 additions & 0 deletions project/librets/include/librets/CurlHttpClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,18 @@ class CurlHttpClient : public RetsHttpClient
*/
virtual void SetTimeout(int seconds);

/**
* Get the path to the CACert.pem file
* @return A string containing the path to cacert.pem
*/
virtual std::string GetCACertPath() { return mCACertPath;};

/**
* Set the path to the CACert.pem file
* @param A string containing the path to cacert.pem
*/
virtual void SetCACertPath(std::string cacert_path) {mCACertPath = cacert_path;};

private:

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

bool mLogging;

std::string mCACertPath;

std::string mUrl;

std::string mUserName;
Expand Down
3 changes: 2 additions & 1 deletion project/librets/src/CurlHttpClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ CurlHttpClient::CurlHttpClient()
*/
curl_global_init(CURL_GLOBAL_ALL);

mCACertPath = "cacert.pem";
mFlags = 0;
mLogger = NullHttpLogger::GetInstance();
mLogging = false;
Expand Down Expand Up @@ -235,7 +236,7 @@ RetsHttpResponsePtr CurlHttpClient::StartRequest(RetsHttpRequest * request)
curlEasy->SetWriteFunction(CurlHttpClient::StaticWriteData);
curlEasy->SetWriteHeaderData(client);
curlEasy->SetWriteHeaderFunction(CurlHttpClient::StaticWriteHeader);
curlEasy->SetCAInfo("cacert.pem");
curlEasy->SetCAInfo(mCACertPath);

if (mFlags & RetsSession::MODE_NO_SSL_VERIFY)
curlEasy->SetSSLVerify(false);
Expand Down
7 changes: 4 additions & 3 deletions project/librets/test/src/PayloadListResultSetTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ void CLASS::testUTF8Response()
* This represents "nunez" with utf8 characters for the accented "u",
* and the "enyay".
*/
const char nunez [] = {0x4e, 0xc3, 0xba, 0xc3, 0xb1, 0x65, 0x7a, 0x00};
unsigned char nunez [] = {0x4e, 0xc3, 0xba, 0xc3, 0xb1, 0x65, 0x7a};
std::string s_nunez(nunez, nunez + sizeof(nunez) / sizeof(nunez[0]));

resultSet.SetEncoding(RETS_XML_DEFAULT_ENCODING);
try
Expand Down Expand Up @@ -265,8 +266,8 @@ void CLASS::testUTF8Response()
ASSERT_STRING_EQUAL("AG000001", resultSet.GetString(0));
ASSERT_STRING_EQUAL("Carlos", resultSet.GetString("FirstName"));
ASSERT_STRING_EQUAL("Carlos", resultSet.GetString(1));
ASSERT_STRING_EQUAL(nunez, resultSet.GetString("LastName"));
ASSERT_STRING_EQUAL(nunez, resultSet.GetString(2));
ASSERT_STRING_EQUAL(s_nunez, resultSet.GetString("LastName"));
ASSERT_STRING_EQUAL(s_nunez, resultSet.GetString(2));

CPPUNIT_ASSERT(!resultSet.HasNext());
}
Expand Down
14 changes: 8 additions & 6 deletions project/librets/test/src/SearchResultSetTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ void CLASS::testExtendedCharResponse()
* This represents "nunez" with extended characters for the accented "u",
* and the "enyay".
*/
const char nunez [] = {0x4e, 0xc2, 0x9c, 0xc2, 0x96, 0x65, 0x7a, 0x00};
unsigned char nunez [] = {0x4e, 0xc2, 0x9c, 0xc2, 0x96, 0x65, 0x7a};
std::string s_nunez(nunez, nunez + sizeof(nunez) / sizeof(nunez[0]));

resultSet.SetEncoding(RETS_XML_DEFAULT_ENCODING);
try
Expand Down Expand Up @@ -315,8 +316,8 @@ void CLASS::testExtendedCharResponse()
ASSERT_STRING_EQUAL("AG000001", resultSet.GetString(0));
ASSERT_STRING_EQUAL("Carlos", resultSet.GetString("FirstName"));
ASSERT_STRING_EQUAL("Carlos", resultSet.GetString(1));
ASSERT_STRING_EQUAL(nunez, resultSet.GetString("LastName"));
ASSERT_STRING_EQUAL(nunez, resultSet.GetString(2));
ASSERT_STRING_EQUAL(s_nunez, resultSet.GetString("LastName"));
ASSERT_STRING_EQUAL(s_nunez, resultSet.GetString(2));

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

resultSet.SetEncoding(RETS_XML_DEFAULT_ENCODING);
try
Expand Down Expand Up @@ -432,8 +434,8 @@ void CLASS::testUTF8Response()
ASSERT_STRING_EQUAL("AG000001", resultSet.GetString(0));
ASSERT_STRING_EQUAL("Carlos", resultSet.GetString("FirstName"));
ASSERT_STRING_EQUAL("Carlos", resultSet.GetString(1));
ASSERT_STRING_EQUAL(nunez, resultSet.GetString("LastName"));
ASSERT_STRING_EQUAL(nunez, resultSet.GetString(2));
ASSERT_STRING_EQUAL(s_nunez, resultSet.GetString("LastName"));
ASSERT_STRING_EQUAL(s_nunez, resultSet.GetString(2));

CPPUNIT_ASSERT(!resultSet.HasNext());
}
Expand Down
5 changes: 3 additions & 2 deletions project/librets/test/src/XmlMetadataParserTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ void CLASS::testExtendedCharacter()
* This represents "nunez" with extended characters for the accented "u",
* and the "enyay".
*/
const char nunez [] = {0x4e, 0xc2, 0x9c, 0xc2, 0x96, 0x65, 0x7a, 0x00};
unsigned char nunez [] = {0x4e, 0xc2, 0x9c, 0xc2, 0x96, 0x65, 0x7a,};
std::string s_nunez(nunez, nunez + sizeof(nunez) / sizeof(nunez[0]));

mParser->SetEncoding(RETS_XML_DEFAULT_ENCODING);

Expand Down Expand Up @@ -298,7 +299,7 @@ void CLASS::testExtendedCharacter()
element->GetStringAttribute("StandardName"));
ASSERT_STRING_EQUAL("Single Family",
element->GetStringAttribute("VisibleName"));
ASSERT_STRING_EQUAL(nunez,
ASSERT_STRING_EQUAL(s_nunez,
element->GetStringAttribute("Description"));
ASSERT_STRING_EQUAL("100.00.001",
element->GetStringAttribute("TableVersion"));
Expand Down

0 comments on commit 683c2f7

Please sign in to comment.