Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CngKey.Import on azure

var rawData = Convert.FromBase64String(_signingKey);
var cng = CngKey.Import(rawData, CngKeyBlobFormat.Pkcs8PrivateBlob);

I use this code to extract key, from embedded base64 string. It works fine when I test it locally but when I publish on azure I get following exception:

WindowsCryptographicException: The system cannot find the file specified

(once again I'm not reading from any file) I need this to communicate with apple apns for push notifications, is there any workaround? And this happens only on free service plan, if I switch to basic plan it's working.

like image 246
Vladimir Sakic Avatar asked Dec 15 '16 13:12

Vladimir Sakic


People also ask

What is cngkey import in CNG?

CngKey Import ( byte [] keyBlob, System.Security.Cryptography.CngKeyBlobFormat format, System.Security.Cryptography.CngProvider provider); An array that contains the key information.

What is import key in azure key?

Imports an externally created key, stores it, and returns key parameters and attributes to the client. The import key operation may be used to import any key type into an Azure Key Vault. If the named key already exists, Azure Key Vault creates a new version of the key. This operation requires the keys/import permission. Name for the imported key.

Which CNG keys are not supported on Windows?

On Windows operating systems before Windows 7 and Windows Server 2008 R2, some CNG key binary large object (BLOB) formats are not supported. Creates a new key by importing the specified key material into the default key storage provider (KSP) and using the specified format.

How do I import a certificate to Microsoft Azure keyvault?

Unzip the file and store it to your local drive so you may import it to Microsoft Azure Keyvault. 3. Import the certificate to Microsoft Azure KeyVault using the command: Your Vault Name. Location in your drive where you store your downloaded certificate file.


2 Answers

Setting WEBSITE_LOAD_USER_PROFILE to equal 1 in the Azure App Service configuration definitely got my remote iOS notifications working. Using dotAPNS for C# .NET I also needed to omit apns.UseSandbox().

like image 128
Carl M. Cartagena Avatar answered Oct 05 '22 23:10

Carl M. Cartagena


I ran into the same error after publishing an existing application to Azure. In my case the problem was solved after I set WEBSITE_LOAD_USER_PROFILE = 1 in App Services / App Name / Application Settings.

like image 44
strohmsn Avatar answered Oct 06 '22 00:10

strohmsn