platform icon indicating copy to clipboard operation
platform copied to clipboard

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

Open lklimek opened this issue 7 months ago • 0 comments

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:

  • [x] I have performed a self-review of my own code
  • [x] 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

lklimek avatar Jul 03 '24 21:07 lklimek