/* created by asn1c */
extern const ASN1_ARRAY_TYPE gnutls_asn1_tab[];
extern const ASN1_ARRAY_TYPE pkix_asn1_tab[];
+extern void *_gnutls_file_mutex;
ASN1_TYPE _gnutls_pkix1_asn;
ASN1_TYPE _gnutls_gnutls_asn;
goto out;
}
+ result = gnutls_mutex_init(&_gnutls_file_mutex);
+ if (result < 0)
+ {
+ gnutls_assert();
+ goto out;
+ }
+
#ifdef ENABLE_PKCS11
gnutls_pkcs11_init (GNUTLS_PKCS11_FLAG_AUTO, NULL);
#endif
#ifdef ENABLE_PKCS11
gnutls_pkcs11_deinit ();
#endif
+ gnutls_mutex_deinit(&_gnutls_file_mutex);
}
_gnutls_init--;
}
#include <base64.h>
#include <gnutls/abstract.h>
#include <system.h>
+#include <locks.h>
static int raw_pubkey_to_base64(const gnutls_datum_t* raw, gnutls_datum_t * b64);
static int x509_crt_to_raw_pubkey(const gnutls_datum_t * cert, gnutls_datum_t *rpubkey);
static int find_config_file(char* file, size_t max_size);
#define MAX_FILENAME 512
+void *_gnutls_file_mutex;
+
static const trust_storage_st default_storage =
{
store_pubkey,
const gnutls_datum_t* pubkey)
{
FILE* fd = NULL;
-gnutls_datum_t b64key;
+gnutls_datum_t b64key = { NULL, 0 };
int ret;
+ ret = gnutls_mutex_lock(&_gnutls_file_mutex);
+ if (ret != 0)
+ return gnutls_assert_val(GNUTLS_E_LOCKING_ERROR);
+
ret = raw_pubkey_to_base64(pubkey, &b64key);
if (ret < 0)
- return gnutls_assert_val(ret);
+ {
+ gnutls_assert();
+ goto cleanup;
+ }
fd = fopen(db_name, "ab+");
if (fd == NULL)
cleanup:
if (fd != NULL)
fclose(fd);
+
+ gnutls_mutex_unlock(&_gnutls_file_mutex);
gnutls_free(b64key.data);
return ret;
* the storage and retrieval of entries. If it is NULL then the
* default file backend will be used.
*
- * Note that this function is not thread safe with the default backend.
- *
* Returns: On success, %GNUTLS_E_SUCCESS (0) is returned, otherwise a
* negative error value.
*