Skip to content

Using PFX files with MSAL for Certificate AuthType#349

Merged
rodrigobr-msft merged 3 commits intomainfrom
users/robrandao/msal-certs
Apr 1, 2026
Merged

Using PFX files with MSAL for Certificate AuthType#349
rodrigobr-msft merged 3 commits intomainfrom
users/robrandao/msal-certs

Conversation

@rodrigobr-msft
Copy link
Copy Markdown
Contributor

This pull request updates the certificate-based authentication flow to use a single PFX certificate file instead of separate PEM and key files. This simplifies configuration and removes unnecessary dependencies. The changes also update the configuration class, its initialization, and related tests to reflect this new approach.

Certificate Authentication Refactor:

  • Replaced usage of separate PEM and key files with a single PFX certificate file (CERT_PFX_FILE) in the AgentAuthConfiguration class and its initialization. All references to CERT_PEM_FILE and CERT_KEY_FILE have been removed and replaced with CERT_PFX_FILE. [1] [2] [3]
  • Updated the MSAL authentication logic to use the PFX certificate file path (private_key_pfx_path) instead of loading and parsing PEM and key files, and removed the calculation of the certificate thumbprint.

Dependency Cleanup:

  • Removed the cryptography library from the package dependencies and imports, as it is no longer needed for certificate parsing. [1] [2]

Test Updates:

  • Updated tests to use the new cert_pfx_file parameter and to check for CERT_PFX_FILE instead of the old PEM/key fields. [1] [2] [3]

Copilot AI review requested due to automatic review settings April 1, 2026 18:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors certificate-based authentication to use a single PFX file with MSAL, removing PEM/key handling and dropping the cryptography dependency.

Changes:

  • Replace CERT_PEM_FILE/CERT_KEY_FILE configuration with CERT_PFX_FILE
  • Update MSAL credential construction to use private_key_pfx_path
  • Update unit tests and dependency list to match the new certificate flow

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
tests/hosting_core/test_auth_configuration.py Updates test inputs/assertions to validate CERT_PFX_FILE instead of PEM/key fields
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/authorization/agent_auth_configuration.py Refactors configuration API and internal fields to support PFX-only certificate configuration
libraries/microsoft-agents-authentication-msal/setup.py Removes cryptography dependency now that PEM parsing is gone
libraries/microsoft-agents-authentication-msal/microsoft_agents/authentication/msal/msal_auth.py Switches MSAL client credential setup to reference a PFX file path

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/hosting_core/test_auth_configuration.py Outdated
…ng/core/authorization/agent_auth_configuration.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 1, 2026 19:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread libraries/microsoft-agents-authentication-msal/setup.py
@rodrigobr-msft rodrigobr-msft marked this pull request as ready for review April 1, 2026 19:10
@rodrigobr-msft rodrigobr-msft requested a review from a team as a code owner April 1, 2026 19:10
@rodrigobr-msft rodrigobr-msft merged commit ac75258 into main Apr 1, 2026
10 checks passed
@rodrigobr-msft rodrigobr-msft deleted the users/robrandao/msal-certs branch April 1, 2026 20:31
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.

3 participants