2
* Copyright (C) 2004,2005 Justin Karneges <justin@affinix.com>
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 Street, Fifth Floor, Boston, MA 02110-1301, USA
20
// need to define this immediately
21
#define _WIN32_WINNT 0x400
23
#include "qca_systemstore.h"
30
bool qca_have_systemstore()
33
HCERTSTORE hSystemStore;
34
hSystemStore = CertOpenSystemStoreA(0, "ROOT");
37
CertCloseStore(hSystemStore, 0);
41
CertificateCollection qca_get_systemstore(const QString &provider)
43
CertificateCollection col;
44
HCERTSTORE hSystemStore;
45
hSystemStore = CertOpenSystemStoreA(0, "ROOT");
48
PCCERT_CONTEXT pc = NULL;
51
pc = CertFindCertificateInStore(
53
X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
60
int size = pc->cbCertEncoded;
61
QByteArray der(size, 0);
62
memcpy(der.data(), pc->pbCertEncoded, size);
64
Certificate cert = Certificate::fromDER(der, 0, provider);
66
col.addCertificate(cert);
68
CertCloseStore(hSystemStore, 0);