Application error on Linux running .net core

Asrar Makrani 1 Reputation point
2022-10-20T05:16:23.41+00:00

I have deployed a .net core application onto Azure App service on Linux. It is working fine locally but on azure we get the inner exception:

The owner of '/home/.dotnet/corefx/cryptography/x509stores/my' is not the current user.

How do we proceed?

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,758 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Lex Li (Microsoft) 5,582 Reputation points Microsoft Employee
    2022-10-21T05:37:35.693+00:00

    The right place to store your certificates is in Azure Key Vault, https://learn.microsoft.com/en-us/azure/key-vault/general/overview

    Then your .NET Core application can query the certificate from there, https://learn.microsoft.com/en-us/azure/key-vault/general/tutorial-net-create-vault-azure-web-app

    0 comments No comments

  2. Asrar Makrani 1 Reputation point
    2022-10-21T05:42:37.753+00:00

    So I had to modify my code after i understood that the certs in Linux are handled differently compared to windows containers. In Linux had to load the cert file directly rather than looking for it in a store.

    private X509Certificate2 GetX509CertificateLinux(string thumbprint)  
        {  
            if (string.IsNullOrEmpty(thumbprint))  
                return null;  
            string finalPath = $"/var/ssl/private/{thumbprint}.p12";  
            var bytes2 = File.ReadAllBytes(finalPath);  
            var cert = new X509Certificate2(bytes2);  
            return cert;  
        }  
    
    0 comments No comments

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.