Crashing when accessing Key Vault from C++ application

Robyn To 0 Reputation points
2024-03-02T00:32:07.3033333+00:00

I am following this guide to connect to my Key Vault from my C++ app:

https://azuresdkdocs.blob.core.windows.net/$web/cpp/azure-security-keyvault-keys/4.1.0/index.html

I am writing in C++ for Unreal.

I am getting a consistent crash when trying to do anything that creates ClientOption like in this line: auto credential = std::make_shared<Azure::Identity::EnvironmentCredential>();

I am using azure-identity from vcpkg, and my call stack is taking me to ClientOptions() = default; in client_options.hpp.

I am hitting a null pointer exception in that ClientOptions() call stack.

Azure Key Vault
Azure Key Vault
An Azure service that is used to manage and protect cryptographic keys and other secrets used by cloud apps and services.
1,284 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,724 questions
{count} votes

1 answer

Sort by: Most helpful
  1. James Hamil 24,661 Reputation points Microsoft Employee
    2024-03-04T20:41:22.5666667+00:00

    Hi @Robyn To , based on the call stack you provided, it seems that the issue is occurring in the ClientOptions constructor. The EnvironmentCredential class is using ClientOptions to create a client for accessing the Key Vault, and it seems that the ClientOptions constructor is encountering a null pointer exception.

    Here are a few things you can try to resolve this issue:

    1. Check that you have correctly configured the environment variables required for authentication. The EnvironmentCredential class uses environment variables to authenticate with Azure services. You can check the required environment variables in the Azure documentation.
    2. Try using a different authentication method, such as ClientSecretCredential or ManagedIdentityCredential, to see if the issue is specific to the EnvironmentCredential class.
    3. Check that you are using the correct version of the azure-identity library. You can check the version in the vcpkg.json file for the library.
    4. Check that you have correctly initialized the ClientOptions object before passing it to the EnvironmentCredential constructor. You can check the required parameters for ClientOptions in the Azure documentation.

    Please let me know if you have any questions and I can help you further.

    If this answer helps you please mark "Accept Answer" so other users can reference it.

    Thank you,

    James


Your answer

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