如何使用Windows sdk和VC ++读取.cer文件? [英] How can I read a .cer file with windows sdk and VC++?
问题描述
您好:
我有一个需要升级的VC ++ MFC应用程序。我的问题是:我必须加载".cer" 文件(不是来自商店的证书,而是文件本身)
并检索一些属性,例如序列号。 我知道使用.NET会更容易,但是我在VC ++中有完整的代码。我已经读过它可以使用
CAPICOM 完成:类似于Certificate.Load(" file.cer"), 但我找不到标题。我试过了
wincrypt.h 功能但不适合我的需求......你能给我一些建议吗?
I have a VC++ MFC application that needs to be upgraded. My problem is: I have to load a ".cer" file (NOT the certificate from a store, but the file itself) and retrieve some attributes, like serial number. I know it would be easier using .NET, but I have the full code in VC++ . I have read it could be done using CAPICOM : something like Certificate.Load("file.cer"), but I can not find the headers. I have tried wincrypt.h functions but none suits my needs... could you give me some suggestions?
非常感谢!!
推荐答案
您是否知道可以将.cer文件作为证书存储区进行访问?
Are you aware that a .cer file can be accessed as a certificate store?
考虑使用CertOpenStore()如下:
Consider using CertOpenStore() as follows:
HCERTSTORE mycer = CertOpenStore (CERT_STORE_PROV_FILENAME, X509_ASN_ENCODING, NULL, (CERT_STORE_OPEN_EXISTING_FLAG | CERT_STORE_READONLY_FLAG), TEXT("myfile.cer") );
这篇关于如何使用Windows sdk和VC ++读取.cer文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!