I have an Azure Worker role that I want to call a Management Service (for example, a REST API) and collect information about related services. However, when I try to upload my certificate, it does not find it. Here are the steps I followed:
1. I created a certificate using MakeCert and registered it as my management certificate through the portal
makecert -r -pe -a sha1 -n "CN = MyCnName" -ss My -len 2048 -sp "Microsoft Enhanced RSA and AES Cryptographic Provider" -sy 24 MyCert.cer
2. Installed the certificate on my local computer, and everything works fine. When running the worker role locally, I can call the management service without problems.
3. Exported the certificate from my computer and registered the exported certificate to the target Hosted Service through the portal
4. The expanded role. When the role starts, it cannot find the certificate.
Here is an excerpt from the code I use to find the certificate.
// Open the certificate store for the current user. var certStore = new X509Store(StoreName.My, StoreLocation.CurrentUser); // I also tried localmachine certStore.Open(OpenFlags.ReadOnly); // Find the certificate with the specified subject. X509Certificate2Collection certCollection = certStore.Certificates.Find( X509FindType.FindBySubjectName, _myConfiguration.SubjectName, false); if (certCollection == null || certCollection.Count < 1) { // Find the certificate with the specified thumbprint. certCollection = certStore.Certificates.Find( X509FindType.FindByThumbprint, _myConfiguration.ThumbPrint, false); } // Close the certificate store. certStore.Close(); // Check to see if a matching certificate was found. if (certCollection.Count == 0) { _logger.Warn("No certificate found"); }
There is no exception, only no certificate was found. Can anyone shed some light on what I need to do?
source share