From: Nikos Mavrogiannopoulos Date: Tue, 6 Sep 2011 14:27:29 +0000 (+0200) Subject: simplified gnutls_certificate_set_x509_trust_file. It uses gnutls_certificate_set_x50... X-Git-Tag: gnutls_3_0_3~49 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3eb56adf2a2307368489fa8bc48f325e224da4e8;p=thirdparty%2Fgnutls.git simplified gnutls_certificate_set_x509_trust_file. It uses gnutls_certificate_set_x509_trust_mem. --- diff --git a/lib/gnutls_x509.c b/lib/gnutls_x509.c index 16c0cf86eb..b3367951c8 100644 --- a/lib/gnutls_x509.c +++ b/lib/gnutls_x509.c @@ -1480,8 +1480,8 @@ gnutls_certificate_set_x509_trust_file (gnutls_certificate_credentials_t cred, gnutls_x509_crt_fmt_t type) { int ret; + gnutls_datum_t cas; size_t size; - char *data; #ifdef ENABLE_PKCS11 if (strncmp (cafile, "pkcs11:", 7) == 0) @@ -1490,19 +1490,18 @@ gnutls_certificate_set_x509_trust_file (gnutls_certificate_credentials_t cred, } #endif - data = read_binary_file (cafile, &size); - if (data == NULL) + cas.data = read_binary_file (cafile, &size); + if (cas.data == NULL) { gnutls_assert (); return GNUTLS_E_FILE_ERROR; } - if (type == GNUTLS_X509_FMT_DER) - ret = parse_der_ca_mem (cred, data, size); - else - ret = parse_pem_ca_mem (cred, data, size); + cas.size = size; - free (data); + ret = gnutls_certificate_set_x509_trust_mem(cred, &cas, type); + + free (cas.data); if (ret < 0) {