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

feat(sdk)!: allow setting CA cert to use when connecting to dapi servers #1924

Open
wants to merge 418 commits into
base: master
Choose a base branch
from

Conversation

lklimek
Copy link
Contributor

@lklimek lklimek commented Jul 3, 2024

Issue being fixed or feature implemented

To intercept traffic, I use mitmproxy.
However, it doesn't support http/3 without tls, and to work with tls I need to set ca certificate inside SDK.

What was done?

Developers can use SdkBuilder::with_ca_certificate to provide CA certificate to use when verifying DAPI certificates.

Added CA cert to DapiClient and AppliedRequestSettings.

This means that AppliedRequestSettings no longer implements Copy trait.

How Has This Been Tested?

  1. Setup local devnet with mitm proxy running with ssl/tls support
  2. In packages/rs-sdk/tests/.env set DASH_SDK_PLATFORM_SSL=true but no SSL cert
  3. Test using cargo test -p dash-sdk --no-default-features -F network-testing test_data_contract_read_not_found; result: error
  4. In packages/rs-sdk/tests/.env set DASH_SDK_PLATFORM_CA_CERT_PATH=/path/to/mitmproxy/cacrt.pem
  5. Run the test again using cargo test -p dash-sdk --no-default-features -F network-testing test_data_contract_read_not_found; result: OK

Breaking Changes

AppliedRequestSettings have one additional field that must be filled (can be None).

AppliedRequestSettings no longer implement Copy trait.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

pauldelucia and others added 30 commits May 7, 2024 19:06
@lklimek lklimek changed the base branch from v1.0-dev to v1.1-dev August 19, 2024 11:37
@lklimek lklimek marked this pull request as ready for review August 19, 2024 11:54
///
/// This is a convenience method that reads the certificate from a file and sets it using
/// [SdkBuilder::with_ca_certificate()].
pub fn with_ca_certificate_file(
Copy link
Contributor

Choose a reason for hiding this comment

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

I think a better approach would be to have just a single with_ca_certificate and expect an actual certificate value, users can figure out where and how to get it as long as it can be constructed

@lklimek lklimek modified the milestones: v1.1.0, v1.2.0 Aug 23, 2024
@shumkov shumkov changed the base branch from v1.1-dev to master August 25, 2024 07:39
@shumkov shumkov requested a review from antouhou as a code owner August 25, 2024 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants