c++ - How do i get Certificate Trust List on windows7 using CryptoAPI -


i want ctl(certificate trust list)on windows7 using crypto api,i use certfindctlinstore function,but return false;the getlasterror() function returns -2146885682,i don't know did wrong. code follow:

hcertstore = certopensystemstore( null, pszstorename);

if(null != hcertstore) {     char buffer[8*1024];     memset(buffer,0,sizeof(buffer));     pcctl_context pctl = certcreatectlcontext(                          x509_asn_encoding|pkcs_7_asn_encoding,                          (const byte*)buffer,                          sizeof(buffer));     ctl_find_usage_para usagepara;     //first     pctl =  certfindctlinstore(             hcertstore,              x509_asn_encoding|pkcs_7_asn_encoding,             0,             ctl_find_any,             null,             null);      if (null != pctl)     {         printf("find ctl\n");     }     else     {         printf("error code :%d\n",getlasterror());     }       //second      crypt_hash_blob cryblob;     pctl =  certfindctlinstore(         hcertstore,          x509_asn_encoding|pkcs_7_asn_encoding,          0,         ctl_find_sha1_hash,         &cryblob,          null);      if (null != pctl)     {         printf("find ctl\n");     }     else     {         printf("error code :%d\n",getlasterror());     }       //third     pctl =  certfindctlinstore(         hcertstore,          x509_asn_encoding|pkcs_7_asn_encoding,          0,         ctl_find_md5_hash,         &cryblob,          null);      if (null != pctl)     {         printf("find ctl\n");     }     else     {         printf("error code :%d\n",getlasterror());     }      //fourth     ctl_find_usage_para ctlpara;     pctl =  certfindctlinstore(         hcertstore,          x509_asn_encoding|pkcs_7_asn_encoding,          0,         ctl_find_usage,         &ctlpara,         null);      if (null != pctl)     {         printf("find ctl\n");     }     else     {         printf("error code :%d\n",getlasterror());     }       //fifth     ctl_find_usage_para ctlpara2;     pctl =  certfindctlinstore(         hcertstore,          x509_asn_encoding|pkcs_7_asn_encoding,          0,         ctl_find_same_usage_flag,         &ctlpara2,          null);      if (null != pctl)     {         printf("find ctl\n");     }     else     {         printf("error code :%d\n",getlasterror());     }       //six     ctl_context ctltext;     pctl =  certfindctlinstore(         hcertstore,          x509_asn_encoding|pkcs_7_asn_encoding,          0,         ctl_find_existing,         &ctltext,          null);      if (null != pctl)     {         printf("find ctl\n");     }     else     {         printf("error code :%d\n",getlasterror());     }      //seven     ctl_find_subject_para ctlsubpara;     pctl =  certfindctlinstore(         hcertstore,          x509_asn_encoding|pkcs_7_asn_encoding,          0,         ctl_find_subject,         &ctlsubpara,          null);      if (null != pctl)     {         printf("find ctl\n");     }     else     {         printf("error code :%d\n",getlasterror());     } 

i bet not getting -2146885682 -2146885628, aka 0x80092004 aka crypt_e_not_found. quite simply, there no ctls in store.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -