how to extract the PFX data from an Azure keyvault to apply to the authentication setting of a Send Message of a logic app

Chris Dent 0 Reputation points
2025-11-25T15:21:45.9966667+00:00

I need to upgrade the authentication on a logic app action Send Messgae tp ClintCertificate.

I have the CA issued certificate in a Keyvault.

When I try to extract the pfx details using

"authentication": {
      "type": "ClientCertificate",
      "pfx": "@{body('Get_Certificate_Keys_secret')?['value']}",
      "password": "@{body('Get_Certificate_Password_secret')?['value']}"

the run errors with

BadRequest Could not load the certificate private key. Please check the authentication certificate password is correct and try again.

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
{count} votes

1 answer

Sort by: Most helpful
  1. Adam Zachary 2,025 Reputation points
    2025-11-25T19:41:52.4033333+00:00

    You’re running into this because Logic Apps can’t use the raw Base64 string from Key Vault as-is.

    When you pull a certificate from Key Vault, the secret value is the full PFX encoded in Base64.

    Logic Apps expects a clean Base64 PFX string with the correct password, and the most common failure is either:

    1. The secret is stored as a Key Vault certificate object, not a secret, or

    The value includes extra JSON fields instead of being the raw Base64 PFX.

    What actually works:

    In Key Vault, go to Certificates → your cert → Download in PFX format.

    Confirm the certificate also created a secret entry. The secret must contain only the Base64 PFX.

    In your Logic App, reference that secret directly:

    "authentication": {
      "type": "ClientCertificate",
      "pfx": "@{body('Get_Certificate_Secret')['value']}",
      "password": "@{body('Get_Certificate_Password')['value']}"
    }
    

    Make sure you use Get Secret, not Get Certificate. The Certificate object returns metadata and won’t work. You must retrieve:

    The certificate’s secret, which is the Base64 PFX

    The password stored as a separate secret

    Once you switch to the secret version of the certificate, the BadRequest error disappears.You’re running into this because Logic Apps can’t use the raw Base64 string from Key Vault as-is. When you pull a certificate from Key Vault, the secret value is the full PFX encoded in Base64. Logic Apps expects a clean Base64 PFX string with the correct password, and the most common failure is either:

    The secret is stored as a Key Vault certificate object, not a secret, or

    The value includes extra JSON fields instead of being the raw Base64 PFX.

    What actually works:

    In Key Vault, go to Certificates → your cert → Download in PFX format.

    Confirm the certificate also created a secret entry. The secret must contain only the Base64 PFX.

    In your Logic App, reference that secret directly:

    "authentication"
    

    Make sure you use Get Secret, not Get Certificate. The Certificate object returns metadata and won’t work. You must retrieve:

    The certificate’s secret, which is the Base64 PFX

    The password stored as a separate secret

    Once you switch to the secret version of the certificate, the BadRequest error disappears.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.