Delphi 7访问Windows X509证书库 [英] Delphi 7 access Windows X509 Certificate Store

查看:656
本文介绍了Delphi 7访问Windows X509证书库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题很简单:有一个简单的方法来访问Windows X509证书存储使用Delphi 7?



在提出这个问题之前,我googled,发现任何有用的信息。

解决方案

最简单的方法是使用capicom,直接击中胜利capi api是痛苦的。 >

注册com对象并从中创建typelib单元。



打开相应的商店,从这里使用certificates()方法。

 
var
store:TStore;
证书:ICertificates;
证书:ICertificate2

store:= TStore.Create(nil);
store.Open(CAPICOM_CURRENT_USER_STORE,'My',CAPICOM_STORE_OPEN_MAXIMUM_ALLOWED或CAPICOM_STORE_OPEN_INCLUDE_ARCHIVED或CAPICOM_STORE_OPEN_EXISTING_ONLY);

证书:= store.Certificates;
for i:= 1 to certificates.count do
begin
certificate:= IInterface(certificates.Item [i])as ICertificate2;
//使用cert
end;

store.close();
store.Free;

capicom参考位于 http://msdn.microsoft.com/en-us/library/ms995332.aspx



如果您确定与花钱,我听到了关于从eldos的PKIBlackbox的好东西。


My question is pretty simple: is there a simple way to access Windows X509 Certificate Store using Delphi 7?

Before asking this question I have googled, but have not found any useful info.

解决方案

the easiest way is to use capicom, hitting the win capi api directly is painful.

once you've registered the com object and created your typelib unit from it..

open the appropriate store, and from there use the certificates() method..

  var
    store: TStore;
    certificates: ICertificates;
    certificate: ICertificate2

  store := TStore.Create(nil);
  store.Open(CAPICOM_CURRENT_USER_STORE, 'My', CAPICOM_STORE_OPEN_MAXIMUM_ALLOWED or CAPICOM_STORE_OPEN_INCLUDE_ARCHIVED or CAPICOM_STORE_OPEN_EXISTING_ONLY);

  certificates := store.Certificates;
  for i := 1 to certificates.count do
  begin
    certificate := IInterface(certificates.Item[i]) as ICertificate2;
    // work with the cert
  end;

  store.close();
  store.Free;

capicom reference is at http://msdn.microsoft.com/en-us/library/ms995332.aspx

if you're ok with spending money, i've heard good things about PKIBlackbox from eldos.

这篇关于Delphi 7访问Windows X509证书库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆