winex11: Keep the result string in the IME UI window procedure.
[wine.git] / dlls / crypt32 / rootstore.c
blob73d954f74047dec7bc58f1a880b233d28f42002b
1 /*
2 * Copyright 2007 Juan Lang
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18 #include "config.h"
19 #include <stdarg.h>
20 #include <stdio.h>
21 #include <sys/types.h>
22 #ifdef HAVE_SYS_STAT_H
23 #include <sys/stat.h>
24 #endif
25 #ifdef HAVE_DIRENT_H
26 #include <dirent.h>
27 #endif
28 #include <fcntl.h>
29 #ifdef HAVE_UNISTD_H
30 #include <unistd.h>
31 #endif
32 #include <errno.h>
33 #include <limits.h>
34 #ifdef HAVE_SECURITY_SECURITY_H
35 #include <Security/Security.h>
36 #endif
37 #include "ntstatus.h"
38 #define WIN32_NO_STATUS
39 #include "windef.h"
40 #include "winbase.h"
41 #include "winreg.h"
42 #include "wincrypt.h"
43 #include "winternl.h"
44 #include "wine/debug.h"
45 #include "crypt32_private.h"
47 WINE_DEFAULT_DEBUG_CHANNEL(crypt);
49 #define INITIAL_CERT_BUFFER 1024
51 struct DynamicBuffer
53 DWORD allocated;
54 DWORD used;
55 BYTE *data;
58 static inline void reset_buffer(struct DynamicBuffer *buffer)
60 buffer->used = 0;
61 if (buffer->data) buffer->data[0] = 0;
64 static BOOL add_line_to_buffer(struct DynamicBuffer *buffer, LPCSTR line)
66 BOOL ret;
68 if (buffer->used + strlen(line) + 1 > buffer->allocated)
70 if (!buffer->allocated)
72 buffer->data = CryptMemAlloc(INITIAL_CERT_BUFFER);
73 if (buffer->data)
75 buffer->data[0] = 0;
76 buffer->allocated = INITIAL_CERT_BUFFER;
79 else
81 DWORD new_size = max(buffer->allocated * 2,
82 buffer->used + strlen(line) + 1);
84 buffer->data = CryptMemRealloc(buffer->data, new_size);
85 if (buffer->data)
86 buffer->allocated = new_size;
89 if (buffer->data)
91 strcpy((char *)buffer->data + strlen((char *)buffer->data), line);
92 /* Not strlen + 1, otherwise we'd count the NULL for every line's
93 * addition (but we overwrite the previous NULL character.) Not an
94 * overrun, we allocate strlen + 1 bytes above.
96 buffer->used += strlen(line);
97 ret = TRUE;
99 else
100 ret = FALSE;
101 return ret;
104 /* Reads any base64-encoded certificates present in fp and adds them to store.
105 * Returns TRUE if any certificates were successfully imported.
107 static BOOL import_base64_certs_from_fp(FILE *fp, HCERTSTORE store)
109 char line[1024];
110 BOOL in_cert = FALSE;
111 struct DynamicBuffer saved_cert = { 0, 0, NULL };
112 int num_certs = 0;
114 TRACE("\n");
115 while (fgets(line, sizeof(line), fp))
117 static const char header[] = "-----BEGIN CERTIFICATE-----";
118 static const char trailer[] = "-----END CERTIFICATE-----";
120 if (!strncmp(line, header, strlen(header)))
122 TRACE("begin new certificate\n");
123 in_cert = TRUE;
124 reset_buffer(&saved_cert);
126 else if (!strncmp(line, trailer, strlen(trailer)))
128 DWORD size;
130 TRACE("end of certificate, adding cert\n");
131 in_cert = FALSE;
132 if (CryptStringToBinaryA((char *)saved_cert.data, saved_cert.used,
133 CRYPT_STRING_BASE64, NULL, &size, NULL, NULL))
135 LPBYTE buf = CryptMemAlloc(size);
137 if (buf)
139 CryptStringToBinaryA((char *)saved_cert.data,
140 saved_cert.used, CRYPT_STRING_BASE64, buf, &size, NULL,
141 NULL);
142 if (CertAddEncodedCertificateToStore(store,
143 X509_ASN_ENCODING, buf, size, CERT_STORE_ADD_NEW, NULL))
144 num_certs++;
145 CryptMemFree(buf);
149 else if (in_cert)
150 add_line_to_buffer(&saved_cert, line);
152 CryptMemFree(saved_cert.data);
153 TRACE("Read %d certs\n", num_certs);
154 return num_certs > 0;
157 static const char *trust_status_to_str(DWORD status)
159 static char buf[1024];
160 int pos = 0;
162 if (status & CERT_TRUST_IS_NOT_TIME_VALID)
163 pos += snprintf(buf + pos, sizeof(buf) - pos, "\n\texpired");
164 if (status & CERT_TRUST_IS_NOT_TIME_NESTED)
165 pos += snprintf(buf + pos, sizeof(buf) - pos, "\n\tbad time nesting");
166 if (status & CERT_TRUST_IS_REVOKED)
167 pos += snprintf(buf + pos, sizeof(buf) - pos, "\n\trevoked");
168 if (status & CERT_TRUST_IS_NOT_SIGNATURE_VALID)
169 pos += snprintf(buf + pos, sizeof(buf) - pos, "\n\tbad signature");
170 if (status & CERT_TRUST_IS_NOT_VALID_FOR_USAGE)
171 pos += snprintf(buf + pos, sizeof(buf) - pos, "\n\tbad usage");
172 if (status & CERT_TRUST_IS_UNTRUSTED_ROOT)
173 pos += snprintf(buf + pos, sizeof(buf) - pos, "\n\tuntrusted root");
174 if (status & CERT_TRUST_REVOCATION_STATUS_UNKNOWN)
175 pos += snprintf(buf + pos, sizeof(buf) - pos,
176 "\n\tunknown revocation status");
177 if (status & CERT_TRUST_IS_CYCLIC)
178 pos += snprintf(buf + pos, sizeof(buf) - pos, "\n\tcyclic chain");
179 if (status & CERT_TRUST_INVALID_EXTENSION)
180 pos += snprintf(buf + pos, sizeof(buf) - pos,
181 "\n\tunsupported critical extension");
182 if (status & CERT_TRUST_INVALID_POLICY_CONSTRAINTS)
183 pos += snprintf(buf + pos, sizeof(buf) - pos, "\n\tbad policy");
184 if (status & CERT_TRUST_INVALID_BASIC_CONSTRAINTS)
185 pos += snprintf(buf + pos, sizeof(buf) - pos,
186 "\n\tbad basic constraints");
187 if (status & CERT_TRUST_INVALID_NAME_CONSTRAINTS)
188 pos += snprintf(buf + pos, sizeof(buf) - pos,
189 "\n\tbad name constraints");
190 if (status & CERT_TRUST_HAS_NOT_SUPPORTED_NAME_CONSTRAINT)
191 pos += snprintf(buf + pos, sizeof(buf) - pos,
192 "\n\tunsupported name constraint");
193 if (status & CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT)
194 pos += snprintf(buf + pos, sizeof(buf) - pos,
195 "\n\tundefined name constraint");
196 if (status & CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT)
197 pos += snprintf(buf + pos, sizeof(buf) - pos,
198 "\n\tdisallowed name constraint");
199 if (status & CERT_TRUST_HAS_EXCLUDED_NAME_CONSTRAINT)
200 pos += snprintf(buf + pos, sizeof(buf) - pos,
201 "\n\texcluded name constraint");
202 if (status & CERT_TRUST_IS_OFFLINE_REVOCATION)
203 pos += snprintf(buf + pos, sizeof(buf) - pos,
204 "\n\trevocation server offline");
205 if (status & CERT_TRUST_NO_ISSUANCE_CHAIN_POLICY)
206 pos += snprintf(buf + pos, sizeof(buf) - pos,
207 "\n\tno issuance policy");
208 return buf;
211 static const char *get_cert_common_name(PCCERT_CONTEXT cert)
213 static char buf[1024];
214 const char *name = NULL;
215 CERT_NAME_INFO *nameInfo;
216 DWORD size;
217 BOOL ret = CryptDecodeObjectEx(X509_ASN_ENCODING, X509_NAME,
218 cert->pCertInfo->Subject.pbData, cert->pCertInfo->Subject.cbData,
219 CRYPT_DECODE_NOCOPY_FLAG | CRYPT_DECODE_ALLOC_FLAG, NULL, &nameInfo,
220 &size);
222 if (ret)
224 PCERT_RDN_ATTR commonName = CertFindRDNAttr(szOID_COMMON_NAME,
225 nameInfo);
227 if (commonName)
229 CertRDNValueToStrA(commonName->dwValueType,
230 &commonName->Value, buf, sizeof(buf));
231 name = buf;
233 LocalFree(nameInfo);
235 return name;
238 static void check_and_store_certs(HCERTSTORE from, HCERTSTORE to)
240 DWORD root_count = 0;
241 CERT_CHAIN_ENGINE_CONFIG chainEngineConfig =
242 { sizeof(chainEngineConfig), 0 };
243 HCERTCHAINENGINE engine;
245 TRACE("\n");
247 CertDuplicateStore(to);
248 engine = CRYPT_CreateChainEngine(to, CERT_SYSTEM_STORE_CURRENT_USER, &chainEngineConfig);
249 if (engine)
251 PCCERT_CONTEXT cert = NULL;
253 do {
254 cert = CertEnumCertificatesInStore(from, cert);
255 if (cert)
257 CERT_CHAIN_PARA chainPara = { sizeof(chainPara), { 0 } };
258 PCCERT_CHAIN_CONTEXT chain;
259 BOOL ret;
261 ret = CertGetCertificateChain(engine, cert, NULL, from,
262 &chainPara, CERT_CHAIN_CACHE_ONLY_URL_RETRIEVAL, NULL, &chain);
263 if (!ret)
264 TRACE("rejecting %s: %s\n", get_cert_common_name(cert),
265 "chain creation failed");
266 else
268 DWORD allowedErrors = CERT_TRUST_IS_UNTRUSTED_ROOT |
269 CERT_TRUST_IS_NOT_VALID_FOR_USAGE |
270 CERT_TRUST_INVALID_BASIC_CONSTRAINTS |
271 CERT_TRUST_IS_NOT_TIME_VALID;
273 /* The certificate chain verification only allows certain
274 * invalid CA certs if they're installed locally: CA
275 * certs missing the key usage extension, and CA certs
276 * missing the basic constraints extension. Of course
277 * there's a chicken and egg problem: we have to accept
278 * them here in order for them to be accepted later.
279 * Expired, locally installed certs are also allowed here,
280 * because we don't know (yet) what date will be checked
281 * for an item signed by one of these certs.
282 * Thus, accept certs with any of the allowed errors.
284 if (chain->TrustStatus.dwErrorStatus & ~allowedErrors)
285 TRACE("rejecting %s: %s\n", get_cert_common_name(cert),
286 trust_status_to_str(chain->TrustStatus.dwErrorStatus &
287 ~CERT_TRUST_IS_UNTRUSTED_ROOT));
288 else
290 DWORD i, j;
292 for (i = 0; i < chain->cChain; i++)
293 for (j = 0; j < chain->rgpChain[i]->cElement; j++)
294 if (CertAddCertificateContextToStore(to,
295 chain->rgpChain[i]->rgpElement[j]->pCertContext,
296 CERT_STORE_ADD_NEW, NULL))
297 root_count++;
299 CertFreeCertificateChain(chain);
302 } while (cert);
303 CertFreeCertificateChainEngine(engine);
305 TRACE("Added %d root certificates\n", root_count);
308 /* Reads the file fd, and imports any certificates in it into store.
309 * Returns TRUE if any certificates were successfully imported.
311 static BOOL import_certs_from_file(int fd, HCERTSTORE store)
313 BOOL ret = FALSE;
314 FILE *fp;
316 TRACE("\n");
318 fp = fdopen(fd, "r");
319 if (fp)
321 ret = import_base64_certs_from_fp(fp, store);
322 fclose(fp);
324 return ret;
327 static BOOL import_certs_from_path(LPCSTR path, HCERTSTORE store,
328 BOOL allow_dir);
330 static BOOL check_buffer_resize(char **ptr_buf, size_t *buf_size, size_t check_size)
332 if (check_size > *buf_size)
334 *buf_size = check_size;
336 if (*ptr_buf)
338 char *realloc_buf = CryptMemRealloc(*ptr_buf, *buf_size);
340 if (!realloc_buf)
341 return FALSE;
343 *ptr_buf = realloc_buf;
345 else
347 *ptr_buf = CryptMemAlloc(*buf_size);
348 if (!*ptr_buf)
349 return FALSE;
353 return TRUE;
356 /* Opens path, which must be a directory, and imports certificates from every
357 * file in the directory into store.
358 * Returns TRUE if any certificates were successfully imported.
360 static BOOL import_certs_from_dir(LPCSTR path, HCERTSTORE store)
362 #ifdef HAVE_READDIR
363 BOOL ret = FALSE;
364 DIR *dir;
366 TRACE("(%s, %p)\n", debugstr_a(path), store);
368 dir = opendir(path);
369 if (dir)
371 size_t path_len = strlen(path), bufsize = 0;
372 char *filebuf = NULL;
374 struct dirent *entry;
375 while ((entry = readdir(dir)))
377 if (strcmp(entry->d_name, ".") && strcmp(entry->d_name, ".."))
379 size_t name_len = strlen(entry->d_name);
381 if (!check_buffer_resize(&filebuf, &bufsize, path_len + 1 + name_len + 1))
383 ERR("Path buffer (re)allocation failed with out of memory condition\n");
384 break;
386 snprintf(filebuf, bufsize, "%s/%s", path, entry->d_name);
387 if (import_certs_from_path(filebuf, store, FALSE) && !ret)
388 ret = TRUE;
391 CryptMemFree(filebuf);
392 closedir(dir);
394 return ret;
395 #else
396 FIXME("not implemented without readdir available\n");
397 return FALSE;
398 #endif
401 /* Opens path, which may be a file or a directory, and imports any certificates
402 * it finds into store.
403 * Returns TRUE if any certificates were successfully imported.
405 static BOOL import_certs_from_path(LPCSTR path, HCERTSTORE store,
406 BOOL allow_dir)
408 BOOL ret = FALSE;
409 int fd;
411 TRACE("(%s, %p, %d)\n", debugstr_a(path), store, allow_dir);
413 fd = open(path, O_RDONLY);
414 if (fd != -1)
416 struct stat st;
418 if (fstat(fd, &st) == 0)
420 if (S_ISREG(st.st_mode))
421 ret = import_certs_from_file(fd, store);
422 else if (S_ISDIR(st.st_mode))
424 if (allow_dir)
425 ret = import_certs_from_dir(path, store);
426 else
427 WARN("%s is a directory and directories are disallowed\n",
428 debugstr_a(path));
430 else
431 ERR("%s: invalid file type\n", path);
433 close(fd);
435 return ret;
438 static const char * const CRYPT_knownLocations[] = {
439 "/etc/ssl/certs/ca-certificates.crt",
440 "/etc/ssl/certs",
441 "/etc/pki/tls/certs/ca-bundle.crt",
442 "/usr/share/ca-certificates/ca-bundle.crt",
443 "/usr/local/share/certs/",
444 "/etc/sfw/openssl/certs",
445 "/etc/security/cacerts", /* Android */
448 static const BYTE authenticode[] = {
449 0x30,0x82,0x03,0xd6,0x30,0x82,0x02,0xbe,0xa0,0x03,0x02,0x01,0x02,0x02,0x01,0x01,
450 0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x04,0x05,0x00,0x30,
451 0x50,0x31,0x0b,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x0d,
452 0x30,0x0b,0x06,0x03,0x55,0x04,0x0a,0x13,0x04,0x4d,0x53,0x46,0x54,0x31,0x32,0x30,
453 0x30,0x06,0x03,0x55,0x04,0x03,0x13,0x29,0x4d,0x69,0x63,0x72,0x6f,0x73,0x6f,0x66,
454 0x74,0x20,0x41,0x75,0x74,0x68,0x65,0x6e,0x74,0x69,0x63,0x6f,0x64,0x65,0x28,0x74,
455 0x6d,0x29,0x20,0x52,0x6f,0x6f,0x74,0x20,0x41,0x75,0x74,0x68,0x6f,0x72,0x69,0x74,
456 0x79,0x30,0x1e,0x17,0x0d,0x39,0x35,0x30,0x31,0x30,0x31,0x30,0x38,0x30,0x30,0x30,
457 0x31,0x5a,0x17,0x0d,0x39,0x39,0x31,0x32,0x33,0x31,0x32,0x33,0x35,0x39,0x35,0x39,
458 0x5a,0x30,0x50,0x31,0x0b,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,
459 0x31,0x0d,0x30,0x0b,0x06,0x03,0x55,0x04,0x0a,0x13,0x04,0x4d,0x53,0x46,0x54,0x31,
460 0x32,0x30,0x30,0x06,0x03,0x55,0x04,0x03,0x13,0x29,0x4d,0x69,0x63,0x72,0x6f,0x73,
461 0x6f,0x66,0x74,0x20,0x41,0x75,0x74,0x68,0x65,0x6e,0x74,0x69,0x63,0x6f,0x64,0x65,
462 0x28,0x74,0x6d,0x29,0x20,0x52,0x6f,0x6f,0x74,0x20,0x41,0x75,0x74,0x68,0x6f,0x72,
463 0x69,0x74,0x79,0x30,0x82,0x01,0x22,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,
464 0x0d,0x01,0x01,0x01,0x05,0x00,0x03,0x82,0x01,0x0f,0x00,0x30,0x82,0x01,0x0a,0x02,
465 0x82,0x01,0x01,0x00,0xdf,0x08,0xba,0xe3,0x3f,0x6e,0x64,0x9b,0xf5,0x89,0xaf,0x28,
466 0x96,0x4a,0x07,0x8f,0x1b,0x2e,0x8b,0x3e,0x1d,0xfc,0xb8,0x80,0x69,0xa3,0xa1,0xce,
467 0xdb,0xdf,0xb0,0x8e,0x6c,0x89,0x76,0x29,0x4f,0xca,0x60,0x35,0x39,0xad,0x72,0x32,
468 0xe0,0x0b,0xae,0x29,0x3d,0x4c,0x16,0xd9,0x4b,0x3c,0x9d,0xda,0xc5,0xd3,0xd1,0x09,
469 0xc9,0x2c,0x6f,0xa6,0xc2,0x60,0x53,0x45,0xdd,0x4b,0xd1,0x55,0xcd,0x03,0x1c,0xd2,
470 0x59,0x56,0x24,0xf3,0xe5,0x78,0xd8,0x07,0xcc,0xd8,0xb3,0x1f,0x90,0x3f,0xc0,0x1a,
471 0x71,0x50,0x1d,0x2d,0xa7,0x12,0x08,0x6d,0x7c,0xb0,0x86,0x6c,0xc7,0xba,0x85,0x32,
472 0x07,0xe1,0x61,0x6f,0xaf,0x03,0xc5,0x6d,0xe5,0xd6,0xa1,0x8f,0x36,0xf6,0xc1,0x0b,
473 0xd1,0x3e,0x69,0x97,0x48,0x72,0xc9,0x7f,0xa4,0xc8,0xc2,0x4a,0x4c,0x7e,0xa1,0xd1,
474 0x94,0xa6,0xd7,0xdc,0xeb,0x05,0x46,0x2e,0xb8,0x18,0xb4,0x57,0x1d,0x86,0x49,0xdb,
475 0x69,0x4a,0x2c,0x21,0xf5,0x5e,0x0f,0x54,0x2d,0x5a,0x43,0xa9,0x7a,0x7e,0x6a,0x8e,
476 0x50,0x4d,0x25,0x57,0xa1,0xbf,0x1b,0x15,0x05,0x43,0x7b,0x2c,0x05,0x8d,0xbd,0x3d,
477 0x03,0x8c,0x93,0x22,0x7d,0x63,0xea,0x0a,0x57,0x05,0x06,0x0a,0xdb,0x61,0x98,0x65,
478 0x2d,0x47,0x49,0xa8,0xe7,0xe6,0x56,0x75,0x5c,0xb8,0x64,0x08,0x63,0xa9,0x30,0x40,
479 0x66,0xb2,0xf9,0xb6,0xe3,0x34,0xe8,0x67,0x30,0xe1,0x43,0x0b,0x87,0xff,0xc9,0xbe,
480 0x72,0x10,0x5e,0x23,0xf0,0x9b,0xa7,0x48,0x65,0xbf,0x09,0x88,0x7b,0xcd,0x72,0xbc,
481 0x2e,0x79,0x9b,0x7b,0x02,0x03,0x01,0x00,0x01,0xa3,0x81,0xba,0x30,0x81,0xb7,0x30,
482 0x0d,0x06,0x03,0x55,0x1d,0x0a,0x04,0x06,0x30,0x04,0x03,0x02,0x07,0x80,0x30,0x32,
483 0x06,0x03,0x55,0x04,0x03,0x04,0x2b,0x13,0x29,0x4d,0x69,0x63,0x72,0x6f,0x73,0x6f,
484 0x66,0x74,0x20,0x41,0x75,0x74,0x68,0x65,0x6e,0x74,0x69,0x63,0x6f,0x64,0x65,0x28,
485 0x74,0x6d,0x29,0x20,0x52,0x6f,0x6f,0x74,0x20,0x41,0x75,0x74,0x68,0x6f,0x72,0x69,
486 0x74,0x79,0x30,0x72,0x06,0x03,0x55,0x1d,0x01,0x04,0x6b,0x30,0x69,0x80,0x10,0x1a,
487 0x1b,0xe7,0x5b,0x9f,0xfd,0x8c,0x2a,0xc3,0x39,0xae,0x0c,0x62,0x2e,0x53,0x32,0xa1,
488 0x52,0x30,0x50,0x31,0x0b,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,
489 0x31,0x0d,0x30,0x0b,0x06,0x03,0x55,0x04,0x0a,0x13,0x04,0x4d,0x53,0x46,0x54,0x31,
490 0x32,0x30,0x30,0x06,0x03,0x55,0x04,0x03,0x13,0x29,0x4d,0x69,0x63,0x72,0x6f,0x73,
491 0x6f,0x66,0x74,0x20,0x41,0x75,0x74,0x68,0x65,0x6e,0x74,0x69,0x63,0x6f,0x64,0x65,
492 0x28,0x74,0x6d,0x29,0x20,0x52,0x6f,0x6f,0x74,0x20,0x41,0x75,0x74,0x68,0x6f,0x72,
493 0x69,0x74,0x79,0x82,0x01,0x01,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,
494 0x01,0x01,0x04,0x05,0x00,0x03,0x82,0x01,0x01,0x00,0x2d,0xc9,0xe2,0xf6,0x12,0x9e,
495 0x5d,0x56,0x67,0xfa,0xfa,0x4b,0x9a,0x7e,0xdc,0x29,0x56,0x5c,0x80,0x14,0x02,0x28,
496 0x85,0x6e,0x26,0xf3,0xcd,0x58,0xda,0x50,0x80,0xc5,0xf8,0x19,0xb3,0xa6,0x7c,0xe2,
497 0x9d,0x6b,0x5f,0x3b,0x8f,0x22,0x74,0xe6,0x18,0x04,0xfc,0x47,0x40,0xd8,0x7a,0x3f,
498 0x30,0x66,0xf0,0x12,0xa4,0xd1,0xeb,0x1d,0xe7,0xb6,0xf4,0x98,0xab,0x53,0x22,0x86,
499 0x51,0x58,0xee,0x23,0x09,0x76,0xe4,0x1d,0x45,0x5c,0x4b,0xff,0x4c,0xe3,0x02,0x50,
500 0x01,0x13,0xcc,0x41,0xa4,0x52,0x97,0xd4,0x86,0xd5,0xc4,0xfe,0x83,0x83,0x65,0x7d,
501 0xea,0xbe,0xa2,0x68,0x3b,0xc1,0xb1,0x29,0x98,0xbf,0xa2,0xa5,0xfc,0x9d,0xd3,0x84,
502 0xee,0x70,0x17,0x50,0xf3,0x0b,0xfa,0x3c,0xef,0xa9,0x27,0x8b,0x91,0xb4,0x48,0xc8,
503 0x45,0xa0,0xe1,0x01,0x42,0x4b,0x44,0x76,0x04,0x1c,0xc2,0x19,0xa2,0x8e,0x6b,0x20,
504 0x98,0xc4,0xdd,0x02,0xac,0xb4,0xd2,0xa2,0x0e,0x8d,0x5d,0xb9,0x36,0x8e,0x4a,0x1b,
505 0x5d,0x6c,0x1a,0xe2,0xcb,0x00,0x7f,0x10,0xf4,0xb2,0x95,0xef,0xe3,0xe8,0xff,0xa1,
506 0x73,0x58,0xa9,0x75,0x2c,0xa2,0x49,0x95,0x85,0xfe,0xcc,0xda,0x44,0x8a,0xc2,0x12,
507 0x44,0xd2,0x44,0xc8,0xa5,0xa2,0x1f,0xa9,0x5a,0x8e,0x56,0xc2,0xc3,0x7b,0xcf,0x42,
508 0x60,0xdc,0x82,0x1f,0xfb,0xce,0x74,0x06,0x7e,0xd6,0xf1,0xac,0x19,0x6a,0x4f,0x74,
509 0x5c,0xc5,0x15,0x66,0x31,0x6c,0xc1,0x62,0x71,0x91,0x0f,0x59,0x5b,0x7d,0x2a,0x82,
510 0x1a,0xdf,0xb1,0xb4,0xd8,0x1d,0x37,0xde,0x0d,0x0f };
511 static const BYTE rootauthority[] = {
512 0x30,0x82,0x04,0x12,0x30,0x82,0x02,0xfa,0xa0,0x03,0x02,0x01,0x02,0x02,0x0f,0x00,
513 0xc1,0x00,0x8b,0x3c,0x3c,0x88,0x11,0xd1,0x3e,0xf6,0x63,0xec,0xdf,0x40,0x30,0x0d,
514 0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x04,0x05,0x00,0x30,0x70,0x31,
515 0x2b,0x30,0x29,0x06,0x03,0x55,0x04,0x0b,0x13,0x22,0x43,0x6f,0x70,0x79,0x72,0x69,
516 0x67,0x68,0x74,0x20,0x28,0x63,0x29,0x20,0x31,0x39,0x39,0x37,0x20,0x4d,0x69,0x63,
517 0x72,0x6f,0x73,0x6f,0x66,0x74,0x20,0x43,0x6f,0x72,0x70,0x2e,0x31,0x1e,0x30,0x1c,
518 0x06,0x03,0x55,0x04,0x0b,0x13,0x15,0x4d,0x69,0x63,0x72,0x6f,0x73,0x6f,0x66,0x74,
519 0x20,0x43,0x6f,0x72,0x70,0x6f,0x72,0x61,0x74,0x69,0x6f,0x6e,0x31,0x21,0x30,0x1f,
520 0x06,0x03,0x55,0x04,0x03,0x13,0x18,0x4d,0x69,0x63,0x72,0x6f,0x73,0x6f,0x66,0x74,
521 0x20,0x52,0x6f,0x6f,0x74,0x20,0x41,0x75,0x74,0x68,0x6f,0x72,0x69,0x74,0x79,0x30,
522 0x1e,0x17,0x0d,0x39,0x37,0x30,0x31,0x31,0x30,0x30,0x37,0x30,0x30,0x30,0x30,0x5a,
523 0x17,0x0d,0x32,0x30,0x31,0x32,0x33,0x31,0x30,0x37,0x30,0x30,0x30,0x30,0x5a,0x30,
524 0x70,0x31,0x2b,0x30,0x29,0x06,0x03,0x55,0x04,0x0b,0x13,0x22,0x43,0x6f,0x70,0x79,
525 0x72,0x69,0x67,0x68,0x74,0x20,0x28,0x63,0x29,0x20,0x31,0x39,0x39,0x37,0x20,0x4d,
526 0x69,0x63,0x72,0x6f,0x73,0x6f,0x66,0x74,0x20,0x43,0x6f,0x72,0x70,0x2e,0x31,0x1e,
527 0x30,0x1c,0x06,0x03,0x55,0x04,0x0b,0x13,0x15,0x4d,0x69,0x63,0x72,0x6f,0x73,0x6f,
528 0x66,0x74,0x20,0x43,0x6f,0x72,0x70,0x6f,0x72,0x61,0x74,0x69,0x6f,0x6e,0x31,0x21,
529 0x30,0x1f,0x06,0x03,0x55,0x04,0x03,0x13,0x18,0x4d,0x69,0x63,0x72,0x6f,0x73,0x6f,
530 0x66,0x74,0x20,0x52,0x6f,0x6f,0x74,0x20,0x41,0x75,0x74,0x68,0x6f,0x72,0x69,0x74,
531 0x79,0x30,0x82,0x01,0x22,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,
532 0x01,0x01,0x05,0x00,0x03,0x82,0x01,0x0f,0x00,0x30,0x82,0x01,0x0a,0x02,0x82,0x01,
533 0x01,0x00,0xa9,0x02,0xbd,0xc1,0x70,0xe6,0x3b,0xf2,0x4e,0x1b,0x28,0x9f,0x97,0x78,
534 0x5e,0x30,0xea,0xa2,0xa9,0x8d,0x25,0x5f,0xf8,0xfe,0x95,0x4c,0xa3,0xb7,0xfe,0x9d,
535 0xa2,0x20,0x3e,0x7c,0x51,0xa2,0x9b,0xa2,0x8f,0x60,0x32,0x6b,0xd1,0x42,0x64,0x79,
536 0xee,0xac,0x76,0xc9,0x54,0xda,0xf2,0xeb,0x9c,0x86,0x1c,0x8f,0x9f,0x84,0x66,0xb3,
537 0xc5,0x6b,0x7a,0x62,0x23,0xd6,0x1d,0x3c,0xde,0x0f,0x01,0x92,0xe8,0x96,0xc4,0xbf,
538 0x2d,0x66,0x9a,0x9a,0x68,0x26,0x99,0xd0,0x3a,0x2c,0xbf,0x0c,0xb5,0x58,0x26,0xc1,
539 0x46,0xe7,0x0a,0x3e,0x38,0x96,0x2c,0xa9,0x28,0x39,0xa8,0xec,0x49,0x83,0x42,0xe3,
540 0x84,0x0f,0xbb,0x9a,0x6c,0x55,0x61,0xac,0x82,0x7c,0xa1,0x60,0x2d,0x77,0x4c,0xe9,
541 0x99,0xb4,0x64,0x3b,0x9a,0x50,0x1c,0x31,0x08,0x24,0x14,0x9f,0xa9,0xe7,0x91,0x2b,
542 0x18,0xe6,0x3d,0x98,0x63,0x14,0x60,0x58,0x05,0x65,0x9f,0x1d,0x37,0x52,0x87,0xf7,
543 0xa7,0xef,0x94,0x02,0xc6,0x1b,0xd3,0xbf,0x55,0x45,0xb3,0x89,0x80,0xbf,0x3a,0xec,
544 0x54,0x94,0x4e,0xae,0xfd,0xa7,0x7a,0x6d,0x74,0x4e,0xaf,0x18,0xcc,0x96,0x09,0x28,
545 0x21,0x00,0x57,0x90,0x60,0x69,0x37,0xbb,0x4b,0x12,0x07,0x3c,0x56,0xff,0x5b,0xfb,
546 0xa4,0x66,0x0a,0x08,0xa6,0xd2,0x81,0x56,0x57,0xef,0xb6,0x3b,0x5e,0x16,0x81,0x77,
547 0x04,0xda,0xf6,0xbe,0xae,0x80,0x95,0xfe,0xb0,0xcd,0x7f,0xd6,0xa7,0x1a,0x72,0x5c,
548 0x3c,0xca,0xbc,0xf0,0x08,0xa3,0x22,0x30,0xb3,0x06,0x85,0xc9,0xb3,0x20,0x77,0x13,
549 0x85,0xdf,0x02,0x03,0x01,0x00,0x01,0xa3,0x81,0xa8,0x30,0x81,0xa5,0x30,0x81,0xa2,
550 0x06,0x03,0x55,0x1d,0x01,0x04,0x81,0x9a,0x30,0x81,0x97,0x80,0x10,0x5b,0xd0,0x70,
551 0xef,0x69,0x72,0x9e,0x23,0x51,0x7e,0x14,0xb2,0x4d,0x8e,0xff,0xcb,0xa1,0x72,0x30,
552 0x70,0x31,0x2b,0x30,0x29,0x06,0x03,0x55,0x04,0x0b,0x13,0x22,0x43,0x6f,0x70,0x79,
553 0x72,0x69,0x67,0x68,0x74,0x20,0x28,0x63,0x29,0x20,0x31,0x39,0x39,0x37,0x20,0x4d,
554 0x69,0x63,0x72,0x6f,0x73,0x6f,0x66,0x74,0x20,0x43,0x6f,0x72,0x70,0x2e,0x31,0x1e,
555 0x30,0x1c,0x06,0x03,0x55,0x04,0x0b,0x13,0x15,0x4d,0x69,0x63,0x72,0x6f,0x73,0x6f,
556 0x66,0x74,0x20,0x43,0x6f,0x72,0x70,0x6f,0x72,0x61,0x74,0x69,0x6f,0x6e,0x31,0x21,
557 0x30,0x1f,0x06,0x03,0x55,0x04,0x03,0x13,0x18,0x4d,0x69,0x63,0x72,0x6f,0x73,0x6f,
558 0x66,0x74,0x20,0x52,0x6f,0x6f,0x74,0x20,0x41,0x75,0x74,0x68,0x6f,0x72,0x69,0x74,
559 0x79,0x82,0x0f,0x00,0xc1,0x00,0x8b,0x3c,0x3c,0x88,0x11,0xd1,0x3e,0xf6,0x63,0xec,
560 0xdf,0x40,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x04,0x05,
561 0x00,0x03,0x82,0x01,0x01,0x00,0x95,0xe8,0x0b,0xc0,0x8d,0xf3,0x97,0x18,0x35,0xed,
562 0xb8,0x01,0x24,0xd8,0x77,0x11,0xf3,0x5c,0x60,0x32,0x9f,0x9e,0x0b,0xcb,0x3e,0x05,
563 0x91,0x88,0x8f,0xc9,0x3a,0xe6,0x21,0xf2,0xf0,0x57,0x93,0x2c,0xb5,0xa0,0x47,0xc8,
564 0x62,0xef,0xfc,0xd7,0xcc,0x3b,0x3b,0x5a,0xa9,0x36,0x54,0x69,0xfe,0x24,0x6d,0x3f,
565 0xc9,0xcc,0xaa,0xde,0x05,0x7c,0xdd,0x31,0x8d,0x3d,0x9f,0x10,0x70,0x6a,0xbb,0xfe,
566 0x12,0x4f,0x18,0x69,0xc0,0xfc,0xd0,0x43,0xe3,0x11,0x5a,0x20,0x4f,0xea,0x62,0x7b,
567 0xaf,0xaa,0x19,0xc8,0x2b,0x37,0x25,0x2d,0xbe,0x65,0xa1,0x12,0x8a,0x25,0x0f,0x63,
568 0xa3,0xf7,0x54,0x1c,0xf9,0x21,0xc9,0xd6,0x15,0xf3,0x52,0xac,0x6e,0x43,0x32,0x07,
569 0xfd,0x82,0x17,0xf8,0xe5,0x67,0x6c,0x0d,0x51,0xf6,0xbd,0xf1,0x52,0xc7,0xbd,0xe7,
570 0xc4,0x30,0xfc,0x20,0x31,0x09,0x88,0x1d,0x95,0x29,0x1a,0x4d,0xd5,0x1d,0x02,0xa5,
571 0xf1,0x80,0xe0,0x03,0xb4,0x5b,0xf4,0xb1,0xdd,0xc8,0x57,0xee,0x65,0x49,0xc7,0x52,
572 0x54,0xb6,0xb4,0x03,0x28,0x12,0xff,0x90,0xd6,0xf0,0x08,0x8f,0x7e,0xb8,0x97,0xc5,
573 0xab,0x37,0x2c,0xe4,0x7a,0xe4,0xa8,0x77,0xe3,0x76,0xa0,0x00,0xd0,0x6a,0x3f,0xc1,
574 0xd2,0x36,0x8a,0xe0,0x41,0x12,0xa8,0x35,0x6a,0x1b,0x6a,0xdb,0x35,0xe1,0xd4,0x1c,
575 0x04,0xe4,0xa8,0x45,0x04,0xc8,0x5a,0x33,0x38,0x6e,0x4d,0x1c,0x0d,0x62,0xb7,0x0a,
576 0xa2,0x8c,0xd3,0xd5,0x54,0x3f,0x46,0xcd,0x1c,0x55,0xa6,0x70,0xdb,0x12,0x3a,0x87,
577 0x93,0x75,0x9f,0xa7,0xd2,0xa0 };
578 static const BYTE rootcertauthority[] = {
579 0x30,0x82,0x05,0x99,0x30,0x82,0x03,0x81,0xa0,0x03,0x02,0x01,0x02,0x02,0x10,0x79,
580 0xad,0x16,0xa1,0x4a,0xa0,0xa5,0xad,0x4c,0x73,0x58,0xf4,0x07,0x13,0x2e,0x65,0x30,
581 0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x05,0x05,0x00,0x30,0x5f,
582 0x31,0x13,0x30,0x11,0x06,0x0a,0x09,0x92,0x26,0x89,0x93,0xf2,0x2c,0x64,0x01,0x19,
583 0x16,0x03,0x63,0x6f,0x6d,0x31,0x19,0x30,0x17,0x06,0x0a,0x09,0x92,0x26,0x89,0x93,
584 0xf2,0x2c,0x64,0x01,0x19,0x16,0x09,0x6d,0x69,0x63,0x72,0x6f,0x73,0x6f,0x66,0x74,
585 0x31,0x2d,0x30,0x2b,0x06,0x03,0x55,0x04,0x03,0x13,0x24,0x4d,0x69,0x63,0x72,0x6f,
586 0x73,0x6f,0x66,0x74,0x20,0x52,0x6f,0x6f,0x74,0x20,0x43,0x65,0x72,0x74,0x69,0x66,
587 0x69,0x63,0x61,0x74,0x65,0x20,0x41,0x75,0x74,0x68,0x6f,0x72,0x69,0x74,0x79,0x30,
588 0x1e,0x17,0x0d,0x30,0x31,0x30,0x35,0x30,0x39,0x32,0x33,0x31,0x39,0x32,0x32,0x5a,
589 0x17,0x0d,0x32,0x31,0x30,0x35,0x30,0x39,0x32,0x33,0x32,0x38,0x31,0x33,0x5a,0x30,
590 0x5f,0x31,0x13,0x30,0x11,0x06,0x0a,0x09,0x92,0x26,0x89,0x93,0xf2,0x2c,0x64,0x01,
591 0x19,0x16,0x03,0x63,0x6f,0x6d,0x31,0x19,0x30,0x17,0x06,0x0a,0x09,0x92,0x26,0x89,
592 0x93,0xf2,0x2c,0x64,0x01,0x19,0x16,0x09,0x6d,0x69,0x63,0x72,0x6f,0x73,0x6f,0x66,
593 0x74,0x31,0x2d,0x30,0x2b,0x06,0x03,0x55,0x04,0x03,0x13,0x24,0x4d,0x69,0x63,0x72,
594 0x6f,0x73,0x6f,0x66,0x74,0x20,0x52,0x6f,0x6f,0x74,0x20,0x43,0x65,0x72,0x74,0x69,
595 0x66,0x69,0x63,0x61,0x74,0x65,0x20,0x41,0x75,0x74,0x68,0x6f,0x72,0x69,0x74,0x79,
596 0x30,0x82,0x02,0x22,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,
597 0x01,0x05,0x00,0x03,0x82,0x02,0x0f,0x00,0x30,0x82,0x02,0x0a,0x02,0x82,0x02,0x01,
598 0x00,0xf3,0x5d,0xfa,0x80,0x67,0xd4,0x5a,0xa7,0xa9,0x0c,0x2c,0x90,0x20,0xd0,0x35,
599 0x08,0x3c,0x75,0x84,0xcd,0xb7,0x07,0x89,0x9c,0x89,0xda,0xde,0xce,0xc3,0x60,0xfa,
600 0x91,0x68,0x5a,0x9e,0x94,0x71,0x29,0x18,0x76,0x7c,0xc2,0xe0,0xc8,0x25,0x76,0x94,
601 0x0e,0x58,0xfa,0x04,0x34,0x36,0xe6,0xdf,0xaf,0xf7,0x80,0xba,0xe9,0x58,0x0b,0x2b,
602 0x93,0xe5,0x9d,0x05,0xe3,0x77,0x22,0x91,0xf7,0x34,0x64,0x3c,0x22,0x91,0x1d,0x5e,
603 0xe1,0x09,0x90,0xbc,0x14,0xfe,0xfc,0x75,0x58,0x19,0xe1,0x79,0xb7,0x07,0x92,0xa3,
604 0xae,0x88,0x59,0x08,0xd8,0x9f,0x07,0xca,0x03,0x58,0xfc,0x68,0x29,0x6d,0x32,0xd7,
605 0xd2,0xa8,0xcb,0x4b,0xfc,0xe1,0x0b,0x48,0x32,0x4f,0xe6,0xeb,0xb8,0xad,0x4f,0xe4,
606 0x5c,0x6f,0x13,0x94,0x99,0xdb,0x95,0xd5,0x75,0xdb,0xa8,0x1a,0xb7,0x94,0x91,0xb4,
607 0x77,0x5b,0xf5,0x48,0x0c,0x8f,0x6a,0x79,0x7d,0x14,0x70,0x04,0x7d,0x6d,0xaf,0x90,
608 0xf5,0xda,0x70,0xd8,0x47,0xb7,0xbf,0x9b,0x2f,0x6c,0xe7,0x05,0xb7,0xe1,0x11,0x60,
609 0xac,0x79,0x91,0x14,0x7c,0xc5,0xd6,0xa6,0xe4,0xe1,0x7e,0xd5,0xc3,0x7e,0xe5,0x92,
610 0xd2,0x3c,0x00,0xb5,0x36,0x82,0xde,0x79,0xe1,0x6d,0xf3,0xb5,0x6e,0xf8,0x9f,0x33,
611 0xc9,0xcb,0x52,0x7d,0x73,0x98,0x36,0xdb,0x8b,0xa1,0x6b,0xa2,0x95,0x97,0x9b,0xa3,
612 0xde,0xc2,0x4d,0x26,0xff,0x06,0x96,0x67,0x25,0x06,0xc8,0xe7,0xac,0xe4,0xee,0x12,
613 0x33,0x95,0x31,0x99,0xc8,0x35,0x08,0x4e,0x34,0xca,0x79,0x53,0xd5,0xb5,0xbe,0x63,
614 0x32,0x59,0x40,0x36,0xc0,0xa5,0x4e,0x04,0x4d,0x3d,0xdb,0x5b,0x07,0x33,0xe4,0x58,
615 0xbf,0xef,0x3f,0x53,0x64,0xd8,0x42,0x59,0x35,0x57,0xfd,0x0f,0x45,0x7c,0x24,0x04,
616 0x4d,0x9e,0xd6,0x38,0x74,0x11,0x97,0x22,0x90,0xce,0x68,0x44,0x74,0x92,0x6f,0xd5,
617 0x4b,0x6f,0xb0,0x86,0xe3,0xc7,0x36,0x42,0xa0,0xd0,0xfc,0xc1,0xc0,0x5a,0xf9,0xa3,
618 0x61,0xb9,0x30,0x47,0x71,0x96,0x0a,0x16,0xb0,0x91,0xc0,0x42,0x95,0xef,0x10,0x7f,
619 0x28,0x6a,0xe3,0x2a,0x1f,0xb1,0xe4,0xcd,0x03,0x3f,0x77,0x71,0x04,0xc7,0x20,0xfc,
620 0x49,0x0f,0x1d,0x45,0x88,0xa4,0xd7,0xcb,0x7e,0x88,0xad,0x8e,0x2d,0xec,0x45,0xdb,
621 0xc4,0x51,0x04,0xc9,0x2a,0xfc,0xec,0x86,0x9e,0x9a,0x11,0x97,0x5b,0xde,0xce,0x53,
622 0x88,0xe6,0xe2,0xb7,0xfd,0xac,0x95,0xc2,0x28,0x40,0xdb,0xef,0x04,0x90,0xdf,0x81,
623 0x33,0x39,0xd9,0xb2,0x45,0xa5,0x23,0x87,0x06,0xa5,0x55,0x89,0x31,0xbb,0x06,0x2d,
624 0x60,0x0e,0x41,0x18,0x7d,0x1f,0x2e,0xb5,0x97,0xcb,0x11,0xeb,0x15,0xd5,0x24,0xa5,
625 0x94,0xef,0x15,0x14,0x89,0xfd,0x4b,0x73,0xfa,0x32,0x5b,0xfc,0xd1,0x33,0x00,0xf9,
626 0x59,0x62,0x70,0x07,0x32,0xea,0x2e,0xab,0x40,0x2d,0x7b,0xca,0xdd,0x21,0x67,0x1b,
627 0x30,0x99,0x8f,0x16,0xaa,0x23,0xa8,0x41,0xd1,0xb0,0x6e,0x11,0x9b,0x36,0xc4,0xde,
628 0x40,0x74,0x9c,0xe1,0x58,0x65,0xc1,0x60,0x1e,0x7a,0x5b,0x38,0xc8,0x8f,0xbb,0x04,
629 0x26,0x7c,0xd4,0x16,0x40,0xe5,0xb6,0x6b,0x6c,0xaa,0x86,0xfd,0x00,0xbf,0xce,0xc1,
630 0x35,0x02,0x03,0x01,0x00,0x01,0xa3,0x51,0x30,0x4f,0x30,0x0b,0x06,0x03,0x55,0x1d,
631 0x0f,0x04,0x04,0x03,0x02,0x01,0xc6,0x30,0x0f,0x06,0x03,0x55,0x1d,0x13,0x01,0x01,
632 0xff,0x04,0x05,0x30,0x03,0x01,0x01,0xff,0x30,0x1d,0x06,0x03,0x55,0x1d,0x0e,0x04,
633 0x16,0x04,0x14,0x0e,0xac,0x82,0x60,0x40,0x56,0x27,0x97,0xe5,0x25,0x13,0xfc,0x2a,
634 0xe1,0x0a,0x53,0x95,0x59,0xe4,0xa4,0x30,0x10,0x06,0x09,0x2b,0x06,0x01,0x04,0x01,
635 0x82,0x37,0x15,0x01,0x04,0x03,0x02,0x01,0x00,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,
636 0x86,0xf7,0x0d,0x01,0x01,0x05,0x05,0x00,0x03,0x82,0x02,0x01,0x00,0xc5,0x11,0x4d,
637 0x03,0x3a,0x60,0xdd,0x5d,0x52,0x11,0x77,0x8f,0xb2,0xbb,0x36,0xc8,0xb2,0x05,0xbf,
638 0xb4,0xb7,0xa8,0xd8,0x20,0x9d,0x5c,0x13,0x03,0xb6,0x1c,0x22,0xfa,0x06,0x13,0x35,
639 0xb6,0xc8,0x63,0xd4,0x9a,0x47,0x6f,0x26,0x57,0xd2,0x55,0xf1,0x04,0xb1,0x26,0x5f,
640 0xd6,0xa9,0x50,0x68,0xa0,0xbc,0xd2,0xb8,0x6e,0xcc,0xc3,0xe9,0xac,0xdf,0x19,0xcd,
641 0x78,0xac,0x59,0x74,0xac,0x66,0x34,0x36,0xc4,0x1b,0x3e,0x6c,0x38,0x4c,0x33,0x0e,
642 0x30,0x12,0x0d,0xa3,0x26,0xfe,0x51,0x53,0x00,0xff,0xaf,0x5a,0x4e,0x84,0x0d,0x0f,
643 0x1f,0xe4,0x6d,0x05,0x2e,0x4e,0x85,0x4b,0x8d,0x6c,0x33,0x6f,0x54,0xd2,0x64,0xab,
644 0xbf,0x50,0xaf,0x7d,0x7a,0x39,0xa0,0x37,0xed,0x63,0x03,0x0f,0xfc,0x13,0x06,0xce,
645 0x16,0x36,0xd4,0x54,0x3b,0x95,0x1b,0x51,0x62,0x3a,0xe5,0x4d,0x17,0xd4,0x05,0x39,
646 0x92,0x9a,0x27,0xa8,0x5b,0xaa,0xbd,0xec,0xbb,0xbe,0xe3,0x20,0x89,0x60,0x71,0x6c,
647 0x56,0xb3,0xa5,0x13,0xd0,0x6d,0x0e,0x23,0x7e,0x95,0x03,0xed,0x68,0x3d,0xf2,0xd8,
648 0x63,0xb8,0x6b,0x4d,0xb6,0xe8,0x30,0xb5,0xe1,0xca,0x94,0x4b,0xf7,0xa2,0xaa,0x5d,
649 0x99,0x30,0xb2,0x3d,0xa7,0xc2,0x51,0x6c,0x28,0x20,0x01,0x24,0x27,0x2b,0x4b,0x00,
650 0xb7,0x9d,0x11,0x6b,0x70,0xbe,0xb2,0x10,0x82,0xbc,0x0c,0x9b,0x68,0xd0,0x8d,0x3b,
651 0x24,0x87,0xaa,0x99,0x28,0x72,0x9d,0x33,0x5f,0x59,0x90,0xbd,0xf5,0xde,0x93,0x9e,
652 0x3a,0x62,0x5a,0x34,0x39,0xe2,0x88,0x55,0x1d,0xb9,0x06,0xb0,0xc1,0x89,0x6b,0x2d,
653 0xd7,0x69,0xc3,0x19,0x12,0x36,0x84,0xd0,0xc9,0xa0,0xda,0xff,0x2f,0x69,0x78,0xb2,
654 0xe5,0x7a,0xda,0xeb,0xd7,0x0c,0xc0,0xf7,0xbd,0x63,0x17,0xb8,0x39,0x13,0x38,0xa2,
655 0x36,0x5b,0x7b,0xf2,0x85,0x56,0x6a,0x1d,0x64,0x62,0xc1,0x38,0xe2,0xaa,0xbf,0x51,
656 0x66,0xa2,0x94,0xf5,0x12,0x9c,0x66,0x22,0x10,0x6b,0xf2,0xb7,0x30,0x92,0x2d,0xf2,
657 0x29,0xf0,0x3d,0x3b,0x14,0x43,0x68,0xa2,0xf1,0x9c,0x29,0x37,0xcb,0xce,0x38,0x20,
658 0x25,0x6d,0x7c,0x67,0xf3,0x7e,0x24,0x12,0x24,0x03,0x08,0x81,0x47,0xec,0xa5,0x9e,
659 0x97,0xf5,0x18,0xd7,0xcf,0xbb,0xd5,0xef,0x76,0x96,0xef,0xfd,0xce,0xdb,0x56,0x9d,
660 0x95,0xa0,0x42,0xf9,0x97,0x58,0xe1,0xd7,0x31,0x22,0xd3,0x5f,0x59,0xe6,0x3e,0x6e,
661 0x22,0x00,0xea,0x43,0x84,0xb6,0x25,0xdb,0xd9,0xf3,0x08,0x56,0x68,0xc0,0x64,0x6b,
662 0x1d,0x7c,0xec,0xb6,0x93,0xa2,0x62,0x57,0x6e,0x2e,0xd8,0xe7,0x58,0x8f,0xc4,0x31,
663 0x49,0x26,0xdd,0xde,0x29,0x35,0x87,0xf5,0x30,0x71,0x70,0x5b,0x14,0x3c,0x69,0xbd,
664 0x89,0x12,0x7d,0xeb,0x2e,0xa3,0xfe,0xd8,0x7f,0x9e,0x82,0x5a,0x52,0x0a,0x2b,0xc1,
665 0x43,0x2b,0xd9,0x30,0x88,0x9f,0xc8,0x10,0xfb,0x89,0x8d,0xe6,0xa1,0x85,0x75,0x33,
666 0x7e,0x6c,0x9e,0xdb,0x73,0x13,0x64,0x62,0x69,0xa5,0x2f,0x7d,0xca,0x96,0x6d,0x9f,
667 0xf8,0x04,0x4d,0x30,0x92,0x3d,0x6e,0x21,0x14,0x21,0xc9,0x3d,0xe0,0xc3,0xfd,0x8a,
668 0x6b,0x9d,0x4a,0xfd,0xd1,0xa1,0x9d,0x99,0x43,0x77,0x3f,0xb0,0xda };
669 static const BYTE rootcertauthority2011[] = {
670 0x30,0x82,0x05,0xed,0x30,0x82,0x03,0xd5,0xa0,0x03,0x02,0x01,0x02,0x02,0x10,0x3f,
671 0x8b,0xc8,0xb5,0xfc,0x9f,0xb2,0x96,0x43,0xb5,0x69,0xd6,0x6c,0x42,0xe1,0x44,0x30,
672 0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x0b,0x05,0x00,0x30,0x81,
673 0x88,0x31,0x0b,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x13,
674 0x30,0x11,0x06,0x03,0x55,0x04,0x08,0x13,0x0a,0x57,0x61,0x73,0x68,0x69,0x6e,0x67,
675 0x74,0x6f,0x6e,0x31,0x10,0x30,0x0e,0x06,0x03,0x55,0x04,0x07,0x13,0x07,0x52,0x65,
676 0x64,0x6d,0x6f,0x6e,0x64,0x31,0x1e,0x30,0x1c,0x06,0x03,0x55,0x04,0x0a,0x13,0x15,
677 0x4d,0x69,0x63,0x72,0x6f,0x73,0x6f,0x66,0x74,0x20,0x43,0x6f,0x72,0x70,0x6f,0x72,
678 0x61,0x74,0x69,0x6f,0x6e,0x31,0x32,0x30,0x30,0x06,0x03,0x55,0x04,0x03,0x13,0x29,
679 0x4d,0x69,0x63,0x72,0x6f,0x73,0x6f,0x66,0x74,0x20,0x52,0x6f,0x6f,0x74,0x20,0x43,
680 0x65,0x72,0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x65,0x20,0x41,0x75,0x74,0x68,0x6f,
681 0x72,0x69,0x74,0x79,0x20,0x32,0x30,0x31,0x31,0x30,0x1e,0x17,0x0d,0x31,0x31,0x30,
682 0x33,0x32,0x32,0x32,0x32,0x30,0x35,0x32,0x38,0x5a,0x17,0x0d,0x33,0x36,0x30,0x33,
683 0x32,0x32,0x32,0x32,0x31,0x33,0x30,0x34,0x5a,0x30,0x81,0x88,0x31,0x0b,0x30,0x09,
684 0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x13,0x30,0x11,0x06,0x03,0x55,
685 0x04,0x08,0x13,0x0a,0x57,0x61,0x73,0x68,0x69,0x6e,0x67,0x74,0x6f,0x6e,0x31,0x10,
686 0x30,0x0e,0x06,0x03,0x55,0x04,0x07,0x13,0x07,0x52,0x65,0x64,0x6d,0x6f,0x6e,0x64,
687 0x31,0x1e,0x30,0x1c,0x06,0x03,0x55,0x04,0x0a,0x13,0x15,0x4d,0x69,0x63,0x72,0x6f,
688 0x73,0x6f,0x66,0x74,0x20,0x43,0x6f,0x72,0x70,0x6f,0x72,0x61,0x74,0x69,0x6f,0x6e,
689 0x31,0x32,0x30,0x30,0x06,0x03,0x55,0x04,0x03,0x13,0x29,0x4d,0x69,0x63,0x72,0x6f,
690 0x73,0x6f,0x66,0x74,0x20,0x52,0x6f,0x6f,0x74,0x20,0x43,0x65,0x72,0x74,0x69,0x66,
691 0x69,0x63,0x61,0x74,0x65,0x20,0x41,0x75,0x74,0x68,0x6f,0x72,0x69,0x74,0x79,0x20,
692 0x32,0x30,0x31,0x31,0x30,0x82,0x02,0x22,0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,
693 0xf7,0x0d,0x01,0x01,0x01,0x05,0x00,0x03,0x82,0x02,0x0f,0x00,0x30,0x82,0x02,0x0a,
694 0x02,0x82,0x02,0x01,0x00,0xb2,0x80,0x41,0xaa,0x35,0x38,0x4d,0x13,0x72,0x32,0x68,
695 0x22,0x4d,0xb8,0xb2,0xf1,0xff,0xd5,0x52,0xbc,0x6c,0xc7,0xf5,0xd2,0x4a,0x8c,0x36,
696 0xee,0xd1,0xc2,0x5c,0x7e,0x8c,0x8a,0xae,0xaf,0x13,0x28,0x6f,0xc0,0x73,0xe3,0x3a,
697 0xce,0xd0,0x25,0xa8,0x5a,0x3a,0x6d,0xef,0xa8,0xb8,0x59,0xab,0x13,0x23,0x68,0xcd,
698 0x0c,0x29,0x87,0xd1,0x6f,0x80,0x5c,0x8f,0x44,0x7f,0x5d,0x90,0x01,0x52,0x58,0xac,
699 0x51,0xc5,0x5f,0x2a,0x87,0xdc,0xdc,0xd8,0x0a,0x1d,0xc1,0x03,0xb9,0x7b,0xb0,0x56,
700 0xe8,0xa3,0xde,0x64,0x61,0xc2,0x9e,0xf8,0xf3,0x7c,0xb9,0xec,0x0d,0xb5,0x54,0xfe,
701 0x4c,0xb6,0x65,0x4f,0x88,0xf0,0x9c,0x48,0x99,0x0c,0x42,0x0b,0x09,0x7c,0x31,0x59,
702 0x17,0x79,0x06,0x78,0x28,0x8d,0x89,0x3a,0x4c,0x03,0x25,0xbe,0x71,0x6a,0x5c,0x0b,
703 0xe7,0x84,0x60,0xa4,0x99,0x22,0xe3,0xd2,0xaf,0x84,0xa4,0xa7,0xfb,0xd1,0x98,0xed,
704 0x0c,0xa9,0xde,0x94,0x89,0xe1,0x0e,0xa0,0xdc,0xc0,0xce,0x99,0x3d,0xea,0x08,0x52,
705 0xbb,0x56,0x79,0xe4,0x1f,0x84,0xba,0x1e,0xb8,0xb4,0xc4,0x49,0x5c,0x4f,0x31,0x4b,
706 0x87,0xdd,0xdd,0x05,0x67,0x26,0x99,0x80,0xe0,0x71,0x11,0xa3,0xb8,0xa5,0x41,0xe2,
707 0xa4,0x53,0xb9,0xf7,0x32,0x29,0x83,0x0c,0x13,0xbf,0x36,0x5e,0x04,0xb3,0x4b,0x43,
708 0x47,0x2f,0x6b,0xe2,0x91,0x1e,0xd3,0x98,0x4f,0xdd,0x42,0x07,0xc8,0xe8,0x1d,0x12,
709 0xfc,0x99,0xa9,0x6b,0x3e,0x92,0x7e,0xc8,0xd6,0x69,0x3a,0xfc,0x64,0xbd,0xb6,0x09,
710 0x9d,0xca,0xfd,0x0c,0x0b,0xa2,0x9b,0x77,0x60,0x4b,0x03,0x94,0xa4,0x30,0x69,0x12,
711 0xd6,0x42,0x2d,0xc1,0x41,0x4c,0xca,0xdc,0xaa,0xfd,0x8f,0x5b,0x83,0x46,0x9a,0xd9,
712 0xfc,0xb1,0xd1,0xe3,0xb3,0xc9,0x7f,0x48,0x7a,0xcd,0x24,0xf0,0x41,0x8f,0x5c,0x74,
713 0xd0,0xac,0xb0,0x10,0x20,0x06,0x49,0xb7,0xc7,0x2d,0x21,0xc8,0x57,0xe3,0xd0,0x86,
714 0xf3,0x03,0x68,0xfb,0xd0,0xce,0x71,0xc1,0x89,0x99,0x4a,0x64,0x01,0x6c,0xfd,0xec,
715 0x30,0x91,0xcf,0x41,0x3c,0x92,0xc7,0xe5,0xba,0x86,0x1d,0x61,0x84,0xc7,0x5f,0x83,
716 0x39,0x62,0xae,0xb4,0x92,0x2f,0x47,0xf3,0x0b,0xf8,0x55,0xeb,0xa0,0x1f,0x59,0xd0,
717 0xbb,0x74,0x9b,0x1e,0xd0,0x76,0xe6,0xf2,0xe9,0x06,0xd7,0x10,0xe8,0xfa,0x64,0xde,
718 0x69,0xc6,0x35,0x96,0x88,0x02,0xf0,0x46,0xb8,0x3f,0x27,0x99,0x6f,0xcb,0x71,0x89,
719 0x29,0x35,0xf7,0x48,0x16,0x02,0x35,0x8f,0xd5,0x79,0x7c,0x4d,0x02,0xcf,0x5f,0xeb,
720 0x8a,0x83,0x4f,0x45,0x71,0x88,0xf9,0xa9,0x0d,0x4e,0x72,0xe9,0xc2,0x9c,0x07,0xcf,
721 0x49,0x1b,0x4e,0x04,0x0e,0x63,0x51,0x8c,0x5e,0xd8,0x00,0xc1,0x55,0x2c,0xb6,0xc6,
722 0xe0,0xc2,0x65,0x4e,0xc9,0x34,0x39,0xf5,0x9c,0xb3,0xc4,0x7e,0xe8,0x61,0x6e,0x13,
723 0x5f,0x15,0xc4,0x5f,0xd9,0x7e,0xed,0x1d,0xce,0xee,0x44,0xec,0xcb,0x2e,0x86,0xb1,
724 0xec,0x38,0xf6,0x70,0xed,0xab,0x5c,0x13,0xc1,0xd9,0x0f,0x0d,0xc7,0x80,0xb2,0x55,
725 0xed,0x34,0xf7,0xac,0x9b,0xe4,0xc3,0xda,0xe7,0x47,0x3c,0xa6,0xb5,0x8f,0x31,0xdf,
726 0xc5,0x4b,0xaf,0xeb,0xf1,0x02,0x03,0x01,0x00,0x01,0xa3,0x51,0x30,0x4f,0x30,0x0b,
727 0x06,0x03,0x55,0x1d,0x0f,0x04,0x04,0x03,0x02,0x01,0x86,0x30,0x0f,0x06,0x03,0x55,
728 0x1d,0x13,0x01,0x01,0xff,0x04,0x05,0x30,0x03,0x01,0x01,0xff,0x30,0x1d,0x06,0x03,
729 0x55,0x1d,0x0e,0x04,0x16,0x04,0x14,0x72,0x2d,0x3a,0x02,0x31,0x90,0x43,0xb9,0x14,
730 0x05,0x4e,0xe1,0xea,0xa7,0xc7,0x31,0xd1,0x23,0x89,0x34,0x30,0x10,0x06,0x09,0x2b,
731 0x06,0x01,0x04,0x01,0x82,0x37,0x15,0x01,0x04,0x03,0x02,0x01,0x00,0x30,0x0d,0x06,
732 0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x0b,0x05,0x00,0x03,0x82,0x02,0x01,
733 0x00,0x7f,0x72,0xcf,0x0f,0xb7,0xc5,0x15,0xdb,0x9b,0xc0,0x49,0xca,0x26,0x5b,0xfe,
734 0x9e,0x13,0xe6,0xd3,0xf0,0xd2,0xdb,0x97,0x5f,0xf2,0x4b,0x3f,0x4d,0xb3,0xae,0x19,
735 0xae,0xed,0xd7,0x97,0xa0,0xac,0xef,0xa9,0x3a,0xa3,0xc2,0x41,0xb0,0xe5,0xb8,0x91,
736 0x9e,0x13,0x81,0x24,0x03,0xe6,0x09,0xfd,0x3f,0x57,0x40,0x39,0x21,0x24,0x56,0xd1,
737 0x10,0x2f,0x4b,0x40,0xa9,0x36,0x86,0x4b,0xb4,0x53,0x57,0x9a,0xfb,0xf1,0x7e,0x89,
738 0x8f,0x11,0xfe,0x18,0x6c,0x51,0xaa,0xe8,0xed,0x09,0x95,0xb5,0xe5,0x71,0xc9,0xa1,
739 0xe9,0x87,0x75,0xa6,0x15,0x7f,0xc9,0x7e,0x37,0x54,0x5e,0x74,0x93,0xc5,0xc3,0x67,
740 0xcc,0x0d,0x4f,0x6b,0xa8,0x17,0x0c,0x6d,0x08,0x92,0x7e,0x8b,0xdd,0x81,0xaa,0x2d,
741 0x70,0x21,0xc3,0x3d,0x06,0x14,0xbb,0xbf,0x24,0x5e,0xa7,0x84,0xd7,0x3f,0x0f,0x21,
742 0x22,0xbd,0x4b,0x00,0x06,0xdb,0x97,0x1c,0xd8,0x5e,0xd4,0xc5,0x0b,0x5c,0x87,0x6e,
743 0x50,0xa4,0xe8,0xc3,0x38,0xa4,0xfb,0xcb,0x2c,0xc5,0x92,0x66,0x9b,0x85,0x5e,0xcb,
744 0x7a,0x6c,0x93,0x7c,0x80,0x29,0x58,0x5b,0x57,0xb5,0x40,0x69,0xba,0x08,0x79,0xa6,
745 0x64,0x62,0x15,0x9d,0x87,0x96,0x45,0xb5,0x66,0x23,0x20,0x03,0x8b,0x1c,0x73,0xa0,
746 0xd3,0xa2,0x79,0x33,0xe0,0x50,0x59,0x86,0xdb,0x2f,0xe5,0x02,0x25,0xea,0x73,0x2a,
747 0x9f,0x00,0x14,0xc8,0x36,0xc7,0x92,0x3b,0xe9,0x4e,0x00,0xec,0xd8,0x56,0x09,0xb9,
748 0x33,0x49,0x12,0xd2,0x54,0x0b,0x01,0xab,0xac,0x47,0xb6,0x91,0x29,0x7d,0x4c,0xb4,
749 0x75,0x80,0x52,0x01,0xe8,0xca,0x82,0xf6,0x9f,0xcc,0xac,0x9c,0x8f,0x17,0xea,0x2f,
750 0x26,0xb0,0xab,0x72,0xac,0x0b,0xfe,0x9e,0x51,0x1e,0xc7,0x43,0x55,0x67,0x4f,0x51,
751 0xb3,0x57,0xd6,0xb6,0xec,0xee,0x52,0xb7,0x3a,0xe9,0x4e,0xe1,0xd7,0x81,0x88,0xbc,
752 0x4f,0x8e,0x75,0xbb,0x4b,0xa8,0xf0,0x35,0xaa,0x26,0xd4,0x67,0x67,0x49,0xb2,0x70,
753 0x4c,0x3b,0x93,0xdc,0x1d,0xdf,0x78,0x90,0x86,0x72,0xb2,0x38,0xa4,0xd1,0xdc,0x92,
754 0x4d,0xc9,0x58,0xeb,0x2b,0x12,0x5c,0xd4,0x3b,0xae,0x8c,0x6b,0xb0,0x83,0xe5,0x01,
755 0x3f,0xf8,0x09,0x32,0xf6,0x93,0x35,0x34,0x22,0xaf,0xdd,0x37,0x0d,0x77,0x09,0x80,
756 0x2b,0xcd,0x48,0x00,0xf1,0x8c,0x99,0x19,0x47,0x05,0x01,0xe9,0xd1,0xbf,0xd1,0x4e,
757 0xd0,0xe6,0x28,0x43,0x37,0x99,0xa4,0x0a,0x4a,0x08,0xd9,0x9a,0x71,0x73,0xd2,0xaa,
758 0xcd,0x31,0x13,0x63,0x76,0xa1,0x37,0x6f,0x92,0x38,0x1e,0x7d,0x12,0x3c,0x66,0x32,
759 0xe7,0xcb,0x6d,0xe1,0xfc,0x52,0x89,0xdd,0xca,0xd6,0x66,0x05,0x9a,0x96,0x61,0xbe,
760 0xa2,0x28,0xc7,0x1c,0xa3,0xa7,0x36,0x50,0x3c,0x3a,0xa4,0xdf,0x4a,0x6e,0xe6,0x87,
761 0x3b,0xce,0xeb,0xf0,0xe0,0x81,0x37,0x9d,0x13,0x3c,0x52,0x8e,0xbd,0xb9,0x1d,0x34,
762 0xc6,0x1d,0xd5,0x0a,0x6a,0x3d,0x98,0x29,0x70,0x8c,0x89,0x2a,0xd1,0xab,0x82,0x10,
763 0x48,0x1f,0xdc,0xf4,0xef,0xa5,0xc5,0xbb,0x55,0x1a,0x38,0x63,0x84,0x4e,0xb7,0x6c,
764 0xad,0x95,0x54,0xec,0x65,0x22,0x10,0x49,0x17,0xb8,0xc0,0x1e,0xc7,0x0f,0xac,0x54,
765 0x47 };
767 static const struct CONST_BLOB {
768 const BYTE *pb;
769 DWORD cb;
770 } msRootCerts[] = {
771 { authenticode, sizeof(authenticode) },
772 { rootauthority, sizeof(rootauthority) },
773 { rootcertauthority, sizeof(rootcertauthority) },
774 { rootcertauthority2011, sizeof(rootcertauthority2011) },
777 static void add_ms_root_certs(HCERTSTORE to)
779 DWORD i;
781 TRACE("\n");
783 for (i = 0; i < sizeof(msRootCerts) / sizeof(msRootCerts[0]); i++)
784 if (!CertAddEncodedCertificateToStore(to, X509_ASN_ENCODING,
785 msRootCerts[i].pb, msRootCerts[i].cb, CERT_STORE_ADD_NEW, NULL))
786 WARN("adding root cert %d failed: %08x\n", i, GetLastError());
789 /* Reads certificates from the list of known locations into store. Stops when
790 * any location contains any certificates, to prevent spending unnecessary time
791 * adding redundant certificates, e.g. when both a certificate bundle and
792 * individual certificates exist in the same directory.
794 static void read_trusted_roots_from_known_locations(HCERTSTORE store)
796 HCERTSTORE from = CertOpenStore(CERT_STORE_PROV_MEMORY,
797 X509_ASN_ENCODING, 0, CERT_STORE_CREATE_NEW_FLAG, NULL);
799 if (from)
801 DWORD i;
802 BOOL ret = FALSE;
804 #ifdef HAVE_SECURITY_SECURITY_H
805 OSStatus status;
806 CFArrayRef rootCerts;
808 status = SecTrustCopyAnchorCertificates(&rootCerts);
809 if (status == noErr)
811 int i;
812 for (i = 0; i < CFArrayGetCount(rootCerts); i++)
814 SecCertificateRef cert = (SecCertificateRef)CFArrayGetValueAtIndex(rootCerts, i);
815 CFDataRef certData;
816 if ((status = SecKeychainItemExport(cert, kSecFormatX509Cert, 0, NULL, &certData)) == noErr)
818 if (CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
819 CFDataGetBytePtr(certData), CFDataGetLength(certData),
820 CERT_STORE_ADD_NEW, NULL))
821 ret = TRUE;
822 else
823 WARN("adding root cert %d failed: %08x\n", i, GetLastError());
824 CFRelease(certData);
826 else
827 WARN("could not export certificate %d to X509 format: 0x%08x\n", i, (unsigned int)status);
829 CFRelease(rootCerts);
831 #endif
833 for (i = 0; !ret &&
834 i < sizeof(CRYPT_knownLocations) / sizeof(CRYPT_knownLocations[0]);
835 i++)
836 ret = import_certs_from_path(CRYPT_knownLocations[i], from, TRUE);
837 check_and_store_certs(from, store);
839 CertCloseStore(from, 0);
842 static HCERTSTORE create_root_store(void)
844 HCERTSTORE memStore = CertOpenStore(CERT_STORE_PROV_MEMORY,
845 X509_ASN_ENCODING, 0, CERT_STORE_CREATE_NEW_FLAG, NULL);
847 if (memStore)
849 read_trusted_roots_from_known_locations(memStore);
850 add_ms_root_certs(memStore);
853 TRACE("returning %p\n", memStore);
854 return memStore;
857 static const WCHAR certs_root_pathW[] =
858 {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
859 'S','y','s','t','e','m','C','e','r','t','i','f','i','c','a','t','e','s','\\',
860 'R','o','o','t','\\', 'C','e','r','t','i','f','i','c','a','t','e','s', 0};
861 static const WCHAR semaphoreW[] =
862 {'c','r','y','p','t','3','2','_','r','o','o','t','_','s','e','m','a','p','h','o','r','e',0};
864 void CRYPT_ImportSystemRootCertsToReg(void)
866 HCERTSTORE store = NULL;
867 HKEY key;
868 LONG rc;
869 HANDLE hsem;
871 static BOOL root_certs_imported = FALSE;
873 if (root_certs_imported)
874 return;
876 hsem = CreateSemaphoreW( NULL, 0, 1, semaphoreW);
877 if (!hsem)
879 ERR("Failed to create semaphore\n");
880 return;
883 if(GetLastError() == ERROR_ALREADY_EXISTS)
884 WaitForSingleObject(hsem, INFINITE);
885 else
887 if ((store = create_root_store()))
889 rc = RegCreateKeyExW(HKEY_LOCAL_MACHINE, certs_root_pathW, 0, NULL, 0,
890 KEY_ALL_ACCESS, NULL, &key, 0);
891 if (!rc)
893 if (!CRYPT_SerializeContextsToReg(key, REG_OPTION_VOLATILE, pCertInterface, store))
894 ERR("Failed to import system certs into registry, %08x\n", GetLastError());
895 RegCloseKey(key);
897 CertCloseStore(store, 0);
898 } else
899 ERR("Failed to create root store\n");
902 root_certs_imported = TRUE;
903 ReleaseSemaphore(hsem, 1, NULL);
904 CloseHandle(hsem);