--- gnutls-3.0.23/lib/gnutls_global.c.orig 2012-04-13 00:05:11 +0400 +++ gnutls-3.0.23/lib/gnutls_global.c 2012-09-05 22:41:33 +0400 @@ -28,6 +28,7 @@ #include #include /* for _gnutls_ext_init */ +#include #include #include #include @@ -270,6 +271,16 @@ goto out; } +#if defined _WIN32 || defined __WIN32__ + result = gnutls_w32crypto_init (); + if (result < 0) + { + gnutls_assert (); + goto out; + } +#endif + + #ifdef ENABLE_PKCS11 gnutls_pkcs11_init (GNUTLS_PKCS11_FLAG_AUTO, NULL); #endif @@ -301,6 +312,9 @@ asn1_delete_structure (&_gnutls_pkix1_asn); _gnutls_crypto_deregister (); _gnutls_cryptodev_deinit (); +#if defined _WIN32 || defined __WIN32__ + gnutls_w32crypto_deinit (); +#endif #ifdef ENABLE_PKCS11 gnutls_pkcs11_deinit (); #endif --- gnutls-3.0.23/lib/gnutls_x509.h.orig 2012-04-13 00:05:11 +0400 +++ gnutls-3.0.23/lib/gnutls_x509.h 2012-09-05 22:50:23 +0400 @@ -40,3 +40,6 @@ int _gnutls_x509_raw_privkey_to_gkey (gnutls_privkey_t * privkey, const gnutls_datum_t * raw_key, gnutls_x509_crt_fmt_t type); + +int gnutls_w32crypto_init (); +void gnutls_w32crypto_deinit (); --- gnutls-3.0.23/lib/gnutls_x509.c.orig 2012-06-06 19:25:41 +0400 +++ gnutls-3.0.23/lib/gnutls_x509.c 2012-09-05 22:50:10 +0400 @@ -44,6 +44,11 @@ #include "read-file.h" #if defined _WIN32 || defined __WIN32__ #include +#if defined(__MINGW32__) && !defined(__MINGW64__) && __MINGW32_MAJOR_VERSION <= 3 && __MINGW32_MINOR_VERSION <= 20 +typedef PCCRL_CONTEXT WINAPI (*Type_CertEnumCRLsInStore) (HCERTSTORE hCertStore, PCCRL_CONTEXT pPrevCrlContext); +static Type_CertEnumCRLsInStore Loaded_CertEnumCRLsInStore; +static HMODULE Crypt32_dll; +#endif #endif /* @@ -1611,7 +1616,7 @@ if (store == NULL) return GNUTLS_E_FILE_ERROR; cert = CertEnumCertificatesInStore(store, NULL); - crl = CertEnumCRLsInStore(store, NULL); + crl = Loaded_CertEnumCRLsInStore(store, NULL); while(cert != NULL) { @@ -1634,7 +1639,7 @@ gnutls_certificate_set_x509_crl_mem(cred, &data, GNUTLS_X509_FMT_DER); } - crl = CertEnumCRLsInStore(store, crl); + crl = Loaded_CertEnumCRLsInStore(store, crl); } CertCloseStore(store, 0); } @@ -2436,3 +2441,34 @@ /* do nothing for now */ return; } + +int +gnutls_w32crypto_init () +{ +#if defined _WIN32 || defined __WIN32__ +#if defined(__MINGW32__) && !defined(__MINGW64__) && __MINGW32_MAJOR_VERSION <= 3 && __MINGW32_MINOR_VERSION <= 20 + HMODULE crypto; + crypto = LoadLibraryA ("Crypt32.dll"); + if (crypto == NULL) + return GNUTLS_E_CRYPTO_INIT_FAILED; + Loaded_CertEnumCRLsInStore = (Type_CertEnumCRLsInStore) GetProcAddress (crypto, "CertEnumCRLsInStore"); + if (Loaded_CertEnumCRLsInStore == NULL) + { + FreeLibrary (crypto); + return GNUTLS_E_CRYPTO_INIT_FAILED; + } + Crypt32_dll = crypto; +#endif +#endif + return 0; +} + +void +gnutls_w32crypto_deinit () +{ +#if defined _WIN32 || defined __WIN32__ +#if defined(__MINGW32__) && !defined(__MINGW64__) && __MINGW32_MAJOR_VERSION <= 3 && __MINGW32_MINOR_VERSION <= 20 + FreeLibrary (Crypt32_dll); +#endif +#endif +}