Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make azure sdk stick to winhttp if possible #851

Merged
merged 3 commits into from
Sep 21, 2023

Conversation

phoebusm
Copy link
Collaborator

Reference Issues/PRs

#849

What does this implement/fix? How does it work (high level)? Highlight notable design decisions.

Azure SDK has an undocumented feature, in the situation which if CA path is set, even it is left empty, uses libcurl instead of the default winhttp as backend support on Windows. During the test, using libcurl as backend shows buggy behaviour on ssl ca cert verification.
This fix is to not set CAINFO if ca path is not specified, to give user choice to use winhttp, to avoid the buggy behaviour.

Any other comments?

Checklist

Checklist for code changes...
  • Have you updated the relevant docstrings and documentation?
  • Is this contribution tested against all ArcticDB's features?
  • Do all exceptions introduced raise appropriate error messages?
  • Are API changes highlighted in the PR description?
  • Is the PR labelled as enhancement or bug so it appears in autogenerated release notes?

@phoebusm phoebusm added the bug Something isn't working label Sep 11, 2023
@phoebusm phoebusm linked an issue Sep 11, 2023 that may be closed by this pull request
@phoebusm phoebusm force-pushed the bugfix/fix_azure_windows_use_libcurl branch from ceefba0 to 55517a9 Compare September 11, 2023 21:13
@phoebusm phoebusm force-pushed the bugfix/fix_azure_windows_use_libcurl branch from 55517a9 to a32523b Compare September 12, 2023 14:26
@phoebusm
Copy link
Collaborator Author

Pending #853 for Azure support on conda build test

@@ -103,6 +103,8 @@ def __init__(self, uri: str, encoding_version: EncodingVersion = DEFAULT_ENCODIN
| | "/etc/pki/tls/cacert.pem" OpenELEC |
| | "/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem" CentOS/RHEL 7 |
| | "/etc/ssl/cert.pem" Alpine Linux |
| | WARNING for WINDOWS USER: Not leaving this empty will switch the backend support of Azure SDK from winhttp to libcurl. If ca cert path is needed to be |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This warning is a bit ungrammatical, and this docstring is getting massive!

But it makes me think, is it ever correct for a Windows user to set CA_cert_path? Shouldn't we leave it to Windows to determine (it doesn't have the Linux "many locations" problem). Should we throw if a Windows user sets this to a non-empty value (and document that)?

I suggest throw if non-empty rather than throw if present so that users can still use the same code across Linux/Windows, just with a bit of config for the cert path location that differs by OS.

Copy link
Collaborator Author

@phoebusm phoebusm Sep 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was torn between should I just simply give exception for it earlier too.
My idea is, there must be a reason for Azure C++ SDK to include libcurl support on Windows. It will be a pity to drop the support on our side. And users need to specifically assign values to CA_cert_path to get themselves into the uncharted territory. As long as warnings are given on the doctoring, users should bear the risk.
I understand my arguments are not strong but I think they are worth being considered.

Copy link
Collaborator Author

@phoebusm phoebusm Sep 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more thing, docstring will be massively reduced once the ca path and directory can be automatically assigned. The commit is coming soon in another branch.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, fair enough. Can I suggest we log a warning on Windows when this is set, then?

What is your comment regarding

using libcurl as backend shows buggy behaviour on ssl ca cert verification. about? What was the buggy behaviour?

It would be good to explain the impact of the change of backend a bit in the log warning.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Text suggestion for this docstring if we keep it:

WARNING for Windows users: Setting this to anything besides an empty string will switch the backend support of Azure SDK from winhttp to libcurl. <EXPLANATION OF IMPACT>

If CA Cert path needs to be specified, set it in the Windows settings rather than using the option, so that winhttp will be used.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could it be that Azure switches to libcurl backend here because it assumes that if CA_Cert_Path is set then it can't be on Windows, or something? It would be good to see if there is anything in the Azure git blame to understand why this happens at all.

Copy link
Collaborator Author

@phoebusm phoebusm Sep 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, fair enough. Can I suggest we log a warning on Windows when this is set, then?

What is your comment regarding

using libcurl as backend shows buggy behaviour on ssl ca cert verification. about? What was the buggy behaviour?

It would be good to explain the impact of the change of backend a bit in the log warning.

Verification fails if SAS Token is used with libcurl on Windows. The problem is gone once switched to winhttp.
I use the word buggy as the fail is weird. You may refer to the corresponding ticket for the details.

Copy link
Collaborator Author

@phoebusm phoebusm Sep 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After an offline discussion with @poodlewars, exception will be thrown if CA_cert_path or CA_cert_dir is being set.
Further compacting of the docstring is handled in #867

python/tests/conftest.py Outdated Show resolved Hide resolved
python/tests/conftest.py Outdated Show resolved Hide resolved
def test_azure_sas_token(azure_account_sas_token, azurite_azure_test_connection_setting):
endpoint, container, credential_name, _, _ = azurite_azure_test_connection_setting
ac = Arctic(
f"azure://DefaultEndpointsProtocol=http;SharedAccessSignature={azure_account_sas_token};BlobEndpoint={endpoint}/{credential_name};Container={container}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should document how to do this in the website

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure I follow? You mean a little guideline to for the users to setup their own SAS tokens?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah exactly, a little example in the docs showing how to connect to Azure with SAS

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@phoebusm phoebusm force-pushed the bugfix/fix_azure_windows_use_libcurl branch 3 times, most recently from e3bb32b to 9699e41 Compare September 20, 2023 16:40
-Drop support of libcurl-backed Azure
@phoebusm phoebusm force-pushed the bugfix/fix_azure_windows_use_libcurl branch from 9699e41 to fe3243a Compare September 20, 2023 17:07
@phoebusm phoebusm merged commit 6013329 into master Sep 21, 2023
98 checks passed
@poodlewars poodlewars deleted the bugfix/fix_azure_windows_use_libcurl branch October 25, 2023 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Connection to Azure blob storage fails if SAS token is used
3 participants