~esignature/esignature/bdoc

« back to all changes in this revision

Viewing changes to debian/libdigidocpp-3.6/src/crypto/cert/MSX509CertStore.cpp

  • Committer: joger quintero
  • Date: 2012-12-20 15:28:28 UTC
  • Revision ID: joger@debian-joger234-20121220152828-nquaoqd20p3bi9lk
.-Se añadió el directorio debian con las fuentes para debianizar.
.-Se añadió el directorio paquetes con el subdirectorio amd64 que contiene los .deb
.-Se corrigió un error en el view.py del cliente python que no mostraba correctamente la verificación de la firma

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "MSX509CertStore.h"
 
2
#include "X509CertStore_p.h"
 
3
 
 
4
#include "../../log.h"
 
5
 
 
6
#include <Windows.h>
 
7
 
 
8
#include <openssl/err.h>
 
9
 
 
10
using namespace digidoc;
 
11
 
 
12
/**
 
13
 * Loads all certificates from system store and adds these to the certificate store.
 
14
 *
 
15
 * @throws IOException exception is throws if failed to open certstore
 
16
 */
 
17
MSX509CertStore::MSX509CertStore() throw(IOException)
 
18
{
 
19
    loadCerts("ROOT");
 
20
    loadCerts("CA");
 
21
    INFO("Loaded %d certificates into certificate store.", sk_X509_num(d->stack));
 
22
}
 
23
 
 
24
/**
 
25
 * Load all certificates found in CertStore and adds these to the cert store.
 
26
 *
 
27
 * @param provider name.
 
28
 * @throws IOException exception is throws if failed open CertStore.
 
29
 */
 
30
void MSX509CertStore::loadCerts(const std::string &provider) throw(IOException)
 
31
{
 
32
    HCERTSTORE s = CertOpenStore(CERT_STORE_PROV_SYSTEM_A,
 
33
        X509_ASN_ENCODING, 0, CERT_SYSTEM_STORE_CURRENT_USER, provider.c_str() );
 
34
    if(!s)
 
35
        THROW_IOEXCEPTION("Failed to ope CertStore with provider %s, can not load cert store.", provider.c_str());
 
36
 
 
37
    PCCERT_CONTEXT pc = 0;
 
38
    while((pc = CertEnumCertificatesInStore(s, pc)))
 
39
    {
 
40
        const unsigned char *pBytes = pc->pbCertEncoded;
 
41
        X509 *c = d2i_X509(0, &pBytes, pc->cbCertEncoded);
 
42
        if(!c)
 
43
            WARN("Cant add cert %ld to X509_STORE, %s", ASN1_INTEGER_get(X509_get_serialNumber(c)), ERR_reason_error_string(ERR_get_error()));
 
44
        sk_X509_push(d->stack, c);
 
45
        if(!X509_STORE_add_cert(d->store, c))
 
46
            WARN("Cant add cert %ld to X509_STORE, %s", ASN1_INTEGER_get(X509_get_serialNumber(c)), ERR_reason_error_string(ERR_get_error()));
 
47
    }
 
48
    CertCloseStore(s, 0);
 
49
}