impl(bq_driver): Implementing Configuration Properties- UseSystemTrustStore#1337
Conversation
f78e8ca to
25bde8b
Compare
25bde8b to
e86eb3f
Compare
| auto conn = std::make_shared<ODBCHandles>(); | ||
| EXPECT_EQ(Connect(kDefaultConnectionString, conn), SQL_SUCCESS); | ||
| std::string connection_string = | ||
| kDefaultConnectionString + ";UseSystemTrustStore=1;"; |
There was a problem hiding this comment.
this is windows only feature , please add a flag
|
|
||
| struct SslCredentials { | ||
| std::string pem_root_certs; | ||
| bool use_system_trust_store = false; |
There was a problem hiding this comment.
let's add this under windows only flag as well
82ac389 to
c1da543
Compare
c1da543 to
ce0946c
Compare
| namespace { | ||
|
|
||
| #ifdef _WIN32 | ||
| std::string ExportWindowsSystemCertsToPem() { |
There was a problem hiding this comment.
please write a unit test case for this
|
@Khushikathuria008 approved, please write unit test case for the function |
| } | ||
|
|
||
| #ifdef _WIN32 | ||
| TEST(ExportWindowsSystemCertsToPemTest, ReturnsValidPemFilePath) { |
There was a problem hiding this comment.
we can combine all these three test cases in one as they are all doing basically the same thing
436e046 to
df80bf2
Compare
| // ----------------------------- | ||
| // Create a REAL temp .pem file directly | ||
| // ----------------------------- | ||
| char temp_path[MAX_PATH]; |
There was a problem hiding this comment.
Don't spend much time on this but verify once if client libraries have a way of setting directly the file contents in binary.
| #ifdef _WIN32 | ||
| // UseSystemTrustStore is only valid on Windows. | ||
| std::string connection_string = | ||
| kDefaultConnectionString + ";UseSystemTrustStore=1;"; |
There was a problem hiding this comment.
This is not validating the behaviour since removing this line will still make the tast succeed.
Please modify an HTAPI test(SQLExecDirect_htapi_basictypes let's say) to disable using the packaged pem file, validate the error, set UseSystemTrustStore . There should be no errors finally.
There was a problem hiding this comment.
Done
Made a separate testcase as this change is only valid for windows.
Existing driver gives error while we do a driver connect whereas our driver gives error when we run a query.
df80bf2 to
a594b6d
Compare
|
|
||
| namespace { | ||
| #ifdef _WIN32 | ||
| std::string ExportWindowsSystemCertsToPem() { |
There was a problem hiding this comment.
Rather than returning empty strings, this function should return StatusRecordOr to handle failures.
| #endif | ||
|
|
||
| namespace { | ||
| google::cloud::ProxyConfig CreateProxyConfig(std::string hostname, |
There was a problem hiding this comment.
Although not related to this change, please remove this function. I cannot find it being used anywhere else . ref.
| *(unsigned long long*)(guid.Data4 + 2)); | ||
|
|
||
| // Build final *.pem path | ||
| std::string pem_file = std::string(temp_path) + "bqca_" + guid_str + ".pem"; |
There was a problem hiding this comment.
We cannot use guid in the file name since it will create a new file every time ExportWindowsSystemCertsToPem is called with ODBCBQClient::CreateBQClient(.
| std::string pem_path; | ||
| if (use_system_trust_store == true) { | ||
| pem_path = ExportWindowsSystemCertsToPem(); | ||
| options.set<google::cloud::CARootsFilePathOption>(pem_path); |
There was a problem hiding this comment.
Why do we need to set it here when we are setting it with read_options also?
This is not needed for REST, right?
sachinpro
left a comment
There was a problem hiding this comment.
I think there is a way to directly use the certificates string. It would be a better implementation if it works.
Let me test it out. I can fix my comments myself alongwith those changes, so no need to update this PR right now.
a594b6d to
af739f1
Compare
af739f1 to
2040107
Compare
2040107 to
ef92796
Compare
ef92796 to
38ac556
Compare
38ac556 to
9aa5b0a
Compare
9aa5b0a to
09a2b1a
Compare
09a2b1a to
25bb9d6
Compare
sachinpro
left a comment
There was a problem hiding this comment.
We need to find a way to have a test to verify this through integration tests.
Currently, UseSystemTrustStore is an optional property. No errors are thrown in either case.
No description provided.