Skip to content

Auto-refresh trust store on certificate error instead of requiring manual flag - #62

Merged
akhanf merged 2 commits into
masterfrom
copilot/enable-refresh-trust-store-automatically
Mar 6, 2026
Merged

akhanf merged 2 commits into
masterfrom
copilot/enable-refresh-trust-store-automatically

Conversation

Copilot AI commented Mar 5, 2026 •

Copy link
Copy Markdown
Contributor

Users encountering TLS certificate failures had to manually re-run with --refresh-trust-store. This change detects certificate errors automatically and retries with a fresh trust store transparently.

Changes

Dcm4cheUtils (dcm4che_utils.py)

  • _CERT_ERROR_PATTERNS — class-level list of Java/dcm4che SSL error strings used for detection (SSLHandshakeException, PKIX path building failed, ValidatorException, etc.)
  • _MAX_RETRY_ATTEMPTS = 2 — named constant for retry limit
  • _build_commands(trust_store_option) — extracted command string construction so it can be called after a trust store refresh
  • __init__ — stores _trust_store_cache_dir, _tls_cipher, _other_options to support rebuilding commands mid-session
  • _is_certificate_error(stderr) — detects cert errors in both bytes and str stderr
  • _refresh_trust_store() — force-refreshes trust store and rebuilds _findscu_str/_getscu_str
  • _execute_findscu_with_xml_output, _execute_findscu_with_xml_output_per_study, retrieve_by_StudyInstanceUID — all now loop up to _MAX_RETRY_ATTEMPTS, calling _refresh_trust_store() and retrying on a first-attempt cert error

Tests (test_dcm4che_utils.py)

  • 7 new unit tests covering _is_certificate_error (positive/negative cases, bytes/str), _refresh_trust_store command rebuild, and retry behaviour in both findscu and getscu paths
Original prompt

This section details on the original issue you should resolve

<issue_title>--refresh-trust-store could be automatically enabled if an exception catches a certificate error</issue_title>
<issue_description>Instead of having users manually run it, would be better to try doing this automatically if an error is detected when trying to download.</issue_description>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: akhanf <11492701+akhanf@users.noreply.github.com>
Copilot AI changed the title [WIP] Automatically enable --refresh-trust-store on certificate errors Auto-refresh trust store on certificate error instead of requiring manual flag Mar 5, 2026
@akhanf
akhanf marked this pull request as ready for review March 6, 2026 02:46
@akhanf
akhanf merged commit 6beabe5 into master Mar 6, 2026
2 checks passed
@akhanf
akhanf deleted the copilot/enable-refresh-trust-store-automatically branch March 6, 2026 02:48
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.

--refresh-trust-store could be automatically enabled if an exception catches a certificate error

2 participants