Mercurial > trustbridge
diff cinst/windowsstore.c @ 219:57bef180d560
Add debug output and make windowsstore linkable from C++ code
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Wed, 26 Mar 2014 20:16:50 +0100 |
parents | 8fb12af98960 |
children | 53ea9b975d1c |
line wrap: on
line diff
--- a/cinst/windowsstore.c Wed Mar 26 20:15:56 2014 +0100 +++ b/cinst/windowsstore.c Wed Mar 26 20:16:50 2014 +0100 @@ -32,7 +32,7 @@ return bufPtr; } -static void +void do_remove(HCERTSTORE hStore, char **to_remove) { PCCERT_CONTEXT pCert = NULL; @@ -48,6 +48,7 @@ char *asn1_data = NULL; size_t asn1_size = 0; int ret = -1; + DWORD j; PCCERT_CONTEXT pc_to_remove = NULL; ret = str_base64_decode (&asn1_data, &asn1_size, to_remove[i], @@ -61,6 +62,7 @@ continue; } + printf ("Deleting cert %s\n", to_remove[i]); pc_to_remove = CertCreateContext (CERT_STORE_CERTIFICATE_CONTEXT, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, (const PBYTE) asn1_data, @@ -86,6 +88,31 @@ pc_to_remove, NULL); + + { + char pszNameString[256]; + if(CertGetNameString( + pc_to_remove, + CERT_NAME_SIMPLE_DISPLAY_TYPE, + 0, + NULL, + pszNameString, + 128)) + { + printf("wanted: %s \n",pszNameString); + } + if(CertGetNameString( + pCert, + CERT_NAME_SIMPLE_DISPLAY_TYPE, + 0, + NULL, + pszNameString, + 128)) + { + printf("got: %s \n",pszNameString); + } + } + CertFreeCertificateContext (pc_to_remove); if (pCert == NULL) @@ -93,6 +120,18 @@ printf ("Did not find certificate\n"); continue; } + for (j = 0; j < pCert->cbCertEncoded; j++) { + if (asn1_data[j] != pCert->pbCertEncoded[j]) { + printf("%1x", (unsigned)(unsigned char)pCert->pbCertEncoded[j]); + } + } + printf("\nWanted: \n"); + for (j = 0; j < pCert->cbCertEncoded; j++) { + if (asn1_data[j] != pCert->pbCertEncoded[j]) { + printf("%1x", (unsigned)(unsigned char)asn1_data[j]); + } + } + printf("\n"); if (!CertDeleteCertificateFromStore (pCert)) { @@ -109,7 +148,7 @@ return; } -static void +void do_install(HCERTSTORE hStore, char **to_install) { int i = 0,