comparison common/certhelp.c @ 1288:265583011f24

(issue123) Add possibility to open native certificate dialog This is currently only implemented for windows.
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 29 Sep 2014 13:12:58 +0200
parents 17e1c8f37d72
children
comparison
equal deleted inserted replaced
1287:d3d66d43365f 1288:265583011f24
48 str = get_oid_valstr(&(chain.subject), oid); 48 str = get_oid_valstr(&(chain.subject), oid);
49 x509_crt_free(&chain); 49 x509_crt_free(&chain);
50 } 50 }
51 return str; 51 return str;
52 } 52 }
53
54 #ifdef WIN32
55 PCCERT_CONTEXT
56 b64_to_cert_context(char *b64_data, size_t b64_size)
57 {
58 size_t buf_size = 0;
59 char *buf = NULL;
60 PCCERT_CONTEXT pCert = NULL;
61 int ret = -1;
62
63 ret = str_base64_decode (&buf, &buf_size, b64_data, b64_size);
64
65 if (ret != 0)
66 {
67 ERRORPRINTF ("decoding certificate failed\n");
68 return NULL;
69 }
70
71 pCert = CertCreateContext (CERT_STORE_CERTIFICATE_CONTEXT,
72 X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
73 (const PBYTE) buf,
74 (DWORD) buf_size,
75 0,
76 NULL);
77 free (buf); /* Windows has a copy */
78
79 if (pCert == NULL)
80 {
81 char *error = getLastErrorMsg();
82 if (error)
83 {
84 ERRORPRINTF ("Failed to create cert context: %s \n", error);
85 free (error);
86 }
87 return NULL;
88 }
89 return pCert;
90 }
91 #endif

http://wald.intevation.org/projects/trustbridge/