dotnet / pinvoke

A library containing all P/Invoke code so you don't have to import it every time. Maintained and updated to support the latest Windows OS.
MIT License
2.12k stars 222 forks source link

PCLCrypto Cert failure for Windows 8.1 and above #330

Closed arun2106 closed 6 years ago

arun2106 commented 7 years ago

Hi,

I am using 2.0.147 version of the dll. My application is targeted for Windows 8.1 and above. But, app cert it failing with Windows OS 10. Can you please help?

This API is not supported for this application type - Api=NCryptCreatePersistedKey. Module=ncrypt.dll. File=PInvoke.NCrypt.dll. This API is not supported for this application type - Api=NCryptDecrypt. Module=ncrypt.dll. File=PInvoke.NCrypt.dll. This API is not supported for this application type - Api=NCryptDeleteKey. Module=ncrypt.dll. File=PInvoke.NCrypt.dll. This API is not supported for this application type - Api=NCryptDeriveKey. Module=ncrypt.dll. File=PInvoke.NCrypt.dll. This API is not supported for this application type - Api=NCryptEncrypt. Module=ncrypt.dll. File=PInvoke.NCrypt.dll. This API is not supported for this application type - Api=NCryptEnumAlgorithms. Module=ncrypt.dll. File=PInvoke.NCrypt.dll. This API is not supported for this application type - Api=NCryptEnumKeys. Module=ncrypt.dll. File=PInvoke.NCrypt.dll. This API is not supported for this application type - Api=NCryptExportKey. Module=ncrypt.dll. File=PInvoke.NCrypt.dll. This API is not supported for this application type - Api=NCryptFinalizeKey. Module=ncrypt.dll. File=PInvoke.NCrypt.dll. This API is not supported for this application type - Api=NCryptFreeBuffer. Module=ncrypt.dll. File=PInvoke.NCrypt.dll. This API is not supported for this application type - Api=NCryptFreeObject. Module=ncrypt.dll. File=PInvoke.NCrypt.dll. This API is not supported for this application type - Api=NCryptGetProperty. Module=ncrypt.dll. File=PInvoke.NCrypt.dll. This API is not supported for this application type - Api=NCryptImportKey. Module=ncrypt.dll. File=PInvoke.NCrypt.dll. This API is not supported for this application type - Api=NCryptIsAlgSupported. Module=ncrypt.dll. File=PInvoke.NCrypt.dll. This API is not supported for this application type - Api=NCryptKeyDerivation. Module=ncrypt.dll. File=PInvoke.NCrypt.dll. This API is not supported for this application type - Api=NCryptOpenKey. Module=ncrypt.dll. File=PInvoke.NCrypt.dll. This API is not supported for this application type - Api=NCryptOpenStorageProvider. Module=ncrypt.dll. File=PInvoke.NCrypt.dll. This API is not supported for this application type - Api=NCryptSecretAgreement. Module=ncrypt.dll. File=PInvoke.NCrypt.dll. This API is not supported for this application type - Api=NCryptSetProperty. Module=ncrypt.dll. File=PInvoke.NCrypt.dll. This API is not supported for this application type - Api=NCryptSignHash. Module=ncrypt.dll. File=PInvoke.NCrypt.dll.

AArnott commented 7 years ago

Duplicate of https://github.com/AArnott/PCLCrypto/issues/97

In particular, I believe https://github.com/AArnott/PCLCrypto/issues/97#issuecomment-304431909 is relevant which talks about how if you update your Win10 SDK you may find it starts working.

arun2106 commented 7 years ago

I tried to certify with windows sdk 10, still same problem. I have tried to remove Pinvoke.Ncrypt, Bcrypt. I am getting application failure, as from pclcrypto to generate keypair, it is referring to ncrypt and failing.

AArnott commented 7 years ago

Which version of the Windows SDK are you using?

AArnott commented 7 years ago

At least one cause for this problem is our lack of using W method suffixes in our P/Invoke attributes.

From this comment:

The actual APIs in Windows are named FindFirstFileExA and FindFirstFileExW, and .NET picks the appropriate one (typically the W version unless you specifically ask for A).

Our FindFirstFileEx method defined here might be revised to add the EntryPoint parameter to the DllImport attribute to include the W suffix:

[DllImport(api_ms_win_core_file_l1_2_0, CharSet = CharSet.Unicode)]
public static unsafe extern SafeFindFilesHandle FindFirstFileEx(string lpFileName, FINDEX_INFO_LEVELS fInfoLevelId, out WIN32_FIND_DATA lpFindFileData, FINDEX_SEARCH_OPS fSearchOp, void* lpSearchFilter, FindFirstFileExFlags dwAdditionalFlags);
AArnott commented 6 years ago

The Windows Store team has fixed this on their end.