[UWP] [C ++] CertificateStores :: FindAllAsync - " MY" store不包含我在当前用户存储中看到的所有证书(使用certmgr) [英] [UWP][C++] CertificateStores::FindAllAsync - "MY" store does not include all the certs what I see in current user store (with certmgr)
问题描述
我想使用证书,存储在SmartCard上的内容。当我将SmartCard插入USB,并使用
certmgr Windows实用程序检查当前用户的证书存储区时,我可以看到证书显示在个人/注册表/证书列表下。
但是,当我尝试在我的UWP应用程序中获取用户个人证书列表时,使用此代码,我看不到存储在USB智能卡上的证书。
CertificateQuery ^ CertQuery = ref new CertificateQuery();
CertQuery-> StoreName =" MY" ;;
create_task(CertificateStores :: FindAllAsync(CertQuery))。then([=](IVectorView< Certificate ^> ^ certs)
{
int i = certs-> size;
for(Certificate ^ cert:certs){
String ^ serialNumber = CryptographicBuffer :: EncodeToHexString(CryptographicBuffer :: CreateFromByteArray(cert-> SerialNumber));
}
});
在 certmgr 实用程序列表中包含3个证书,包括USB SmartCard证书,此代码列表(证书 - > Size)只有2个证书,不包括我的USB SmartCard证书。
(appxmanifest包含< uap:Capability Name =" sharedUserCertificates" />物业。)
有人可以帮我解决问题吗?谢谢!
$
我在我的电脑上测试了这个问题。插入SmartCard后,可以自动导入证书。并且可以通过certmgr工具在证书 - 当前用户\个人版权证书中查询证书。我不确定为什么证书
出现在Personal / 注册表 /证书列表下。我想您可以尝试将查询更改为以下代码。
CertificateQuery ^ CertQuery = ref new CertificateQuery() ;
// CertQuery-> StoreName =" MY" ;;
CertQuery-> HardwareOnly = true;
create_task(CertificateStores :: FindAllAsync(CertQuery))。then([=](IVectorView< Certificate ^> ^ certs)
{
int i = certs->大小;
for(Certificate ^ cert:certs){
String ^ serialNumber = CryptographicBuffer :: EncodeToHexString(CryptographicBuffer :: CreateFromByteArray(cert-> SerialNumber));
}
});
最好的问候
Roy
I would like to use a certificate, what is stored on a SmartCard. When I insert the SmartCard into the USB, and check the current user's certificate store with
certmgr Windows utility, I can see the certificate appears under the Personal/Registry/Certificates list.
But, when I try to get the user personal certificate list in my UWP application, using this code, I can not see the certificate stored on the USB SmartCard.
CertificateQuery^ CertQuery = ref new CertificateQuery(); CertQuery->StoreName = "MY"; create_task(CertificateStores::FindAllAsync(CertQuery)).then([=](IVectorView<Certificate^>^ certs) { int i = certs->Size; for (Certificate^ cert : certs) { String^ serialNumber = CryptographicBuffer::EncodeToHexString(CryptographicBuffer::CreateFromByteArray(cert->SerialNumber)); } });
While in the list of the certmgr utility includes 3 certificates, including the USB SmartCard cert, the list of this code (certs->Size) has only 2 certs, excluding my USB SmartCard cert.
(The appxmanifest contains the <uap:Capability Name="sharedUserCertificates" /> property.)
Could someone help me, where the problem might be? Thanks!
Hi,
I have tested this issue on my PC. When the SmartCard is inserted, the certificate could be imported automatically. And the certificate could be queried in Certificates - Current User\Personal\Certificates via certmgr tool. I’m not sure why the certificate appears under the Personal/Registry/Certificates list. I think you can try to change the query as following code.
CertificateQuery^ CertQuery = ref new CertificateQuery(); //CertQuery->StoreName = "MY"; CertQuery->HardwareOnly = true; create_task(CertificateStores::FindAllAsync(CertQuery)).then([=](IVectorView<Certificate^>^ certs) { int i = certs->Size; for (Certificate^ cert : certs) { String^ serialNumber = CryptographicBuffer::EncodeToHexString(CryptographicBuffer::CreateFromByteArray(cert->SerialNumber)); } });
Best Regards
Roy
这篇关于[UWP] [C ++] CertificateStores :: FindAllAsync - " MY" store不包含我在当前用户存储中看到的所有证书(使用certmgr)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!